Skip to content

Commit

Permalink
chore: add tests and final edits
Browse files Browse the repository at this point in the history
  • Loading branch information
pranav-new-relic committed Dec 11, 2023
1 parent 688c7cd commit 14bda88
Show file tree
Hide file tree
Showing 3 changed files with 438 additions and 43 deletions.
23 changes: 11 additions & 12 deletions newrelic/resource_newrelic_monitor_downtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func resourceNewRelicMonitorDowntimeCreate(ctx context.Context, d *schema.Resour
}

switch commonArgumentsObject.Mode {
case "ONE_TIME":
case SyntheticsMonitorDowntimeModes.ONE_TIME:
oneTimeCreateObject, err := getMonitorDowntimeOneTimeValues(d, commonArgumentsObject)
if err != nil {
return diag.FromErr(err)
Expand All @@ -182,7 +182,7 @@ func resourceNewRelicMonitorDowntimeCreate(ctx context.Context, d *schema.Resour

d.SetId(guid)
break
case "DAILY":
case SyntheticsMonitorDowntimeModes.DAILY:
dailyCreateObject, err := getMonitorDowntimeDailyValues(d, commonArgumentsObject)
if err != nil {
return diag.FromErr(err)
Expand All @@ -196,7 +196,7 @@ func resourceNewRelicMonitorDowntimeCreate(ctx context.Context, d *schema.Resour

d.SetId(guid)
break
case "WEEKLY":
case SyntheticsMonitorDowntimeModes.WEEKLY:
weeklyCreateObject, err := getMonitorDowntimeWeeklyValues(d, commonArgumentsObject)
if err != nil {
return diag.FromErr(err)
Expand All @@ -210,7 +210,7 @@ func resourceNewRelicMonitorDowntimeCreate(ctx context.Context, d *schema.Resour

d.SetId(guid)
break
case "MONTHLY":
case SyntheticsMonitorDowntimeModes.MONTHLY:
monthlyCreateObject, err := getMonitorDowntimeMonthlyValues(d, commonArgumentsObject)
if err != nil {
return diag.FromErr(err)
Expand Down Expand Up @@ -261,22 +261,21 @@ func resourceNewRelicMonitorDowntimeRead(ctx context.Context, d *schema.Resource
mode := setMonitorDowntimeMode(tags)
timezone := setMonitorDowntimeTimezone(tags)
_ = d.Set("name", entity.GetName())
_ = d.Set("monitor_guids", setMonitorDowntimeMonitorGUIDs(entity.GetRelationships(), common.EntityGUID(d.Id())))
_ = d.Set("account_id", setMonitorDowntimeAccountId(tags))
_ = d.Set("mode", mode)
_ = d.Set("start_time", setMonitorDowntimeStartTime(tags))
_ = d.Set("end_time", setMonitorDowntimeEndTime(tags))
_ = d.Set("time_zone", timezone)

if mode != "ONE_TIME" {
if mode != SyntheticsMonitorDowntimeModes.ONE_TIME {
setMonitorDowntimeEndRepeat(d, tags, timezone)
}

if mode == "WEEKLY" {
if mode == SyntheticsMonitorDowntimeModes.WEEKLY {
setMonitorDowntimeMaintenanceDays(d, tags)
}

if mode == "MONTHLY" {
if mode == SyntheticsMonitorDowntimeModes.MONTHLY {
setMonitorDowntimeFrequency(d, tags)
}
return nil
Expand All @@ -292,7 +291,7 @@ func resourceNewRelicMonitorDowntimeUpdate(ctx context.Context, d *schema.Resour
}

switch commonArgumentsObject.Mode {
case "ONE_TIME":
case SyntheticsMonitorDowntimeModes.ONE_TIME:
oneTimeUpdateObject, err := getMonitorDowntimeOneTimeValues(d, commonArgumentsObject)
if err != nil {
return diag.FromErr(err)
Expand All @@ -306,7 +305,7 @@ func resourceNewRelicMonitorDowntimeUpdate(ctx context.Context, d *schema.Resour

d.SetId(guid)
break
case "DAILY":
case SyntheticsMonitorDowntimeModes.DAILY:
dailyUpdateObject, err := getMonitorDowntimeDailyValues(d, commonArgumentsObject)
if err != nil {
return diag.FromErr(err)
Expand All @@ -320,7 +319,7 @@ func resourceNewRelicMonitorDowntimeUpdate(ctx context.Context, d *schema.Resour

d.SetId(guid)
break
case "WEEKLY":
case SyntheticsMonitorDowntimeModes.WEEKLY:
weeklyUpdateObject, err := getMonitorDowntimeWeeklyValues(d, commonArgumentsObject)
if err != nil {
return diag.FromErr(err)
Expand All @@ -334,7 +333,7 @@ func resourceNewRelicMonitorDowntimeUpdate(ctx context.Context, d *schema.Resour

d.SetId(guid)
break
case "MONTHLY":
case SyntheticsMonitorDowntimeModes.MONTHLY:
monthlyUpdateObject, err := getMonitorDowntimeMonthlyValues(d, commonArgumentsObject)
if err != nil {
return diag.FromErr(err)
Expand Down
Loading

0 comments on commit 14bda88

Please sign in to comment.