|  | 
| 6 | 6 | 
 | 
| 7 | 7 | 	"github.com/elastic/terraform-provider-elasticstack/generated/kbapi" | 
| 8 | 8 | 	"github.com/elastic/terraform-provider-elasticstack/internal/clients" | 
|  | 9 | +	"github.com/elastic/terraform-provider-elasticstack/internal/utils" | 
| 9 | 10 | 	"github.com/hashicorp/terraform-plugin-framework/diag" | 
| 10 | 11 | 	"github.com/hashicorp/terraform-plugin-framework/types" | 
| 11 | 12 | ) | 
| @@ -79,19 +80,19 @@ func (model MaintenanceWindowModel) toAPICreateRequest(ctx context.Context) (kba | 
| 79 | 80 | 			body.Schedule.Custom.Recurring.Occurrences = &occurrences | 
| 80 | 81 | 		} | 
| 81 | 82 | 
 | 
| 82 |  | -		if !model.CustomSchedule.Recurring.OnWeekDay.IsNull() && !model.CustomSchedule.Recurring.OnWeekDay.IsUnknown() { | 
|  | 83 | +		if utils.IsKnown(model.CustomSchedule.Recurring.OnWeekDay) { | 
| 83 | 84 | 			var onWeekDay []string | 
| 84 | 85 | 			diags.Append(model.CustomSchedule.Recurring.OnWeekDay.ElementsAs(ctx, &onWeekDay, true)...) | 
| 85 | 86 | 			body.Schedule.Custom.Recurring.OnWeekDay = &onWeekDay | 
| 86 | 87 | 		} | 
| 87 | 88 | 
 | 
| 88 |  | -		if !model.CustomSchedule.Recurring.OnMonth.IsNull() && !model.CustomSchedule.Recurring.OnMonth.IsUnknown() { | 
|  | 89 | +		if utils.IsKnown(model.CustomSchedule.Recurring.OnMonth) { | 
| 89 | 90 | 			var onMonth []float32 | 
| 90 | 91 | 			diags.Append(model.CustomSchedule.Recurring.OnMonth.ElementsAs(ctx, &onMonth, true)...) | 
| 91 | 92 | 			body.Schedule.Custom.Recurring.OnMonth = &onMonth | 
| 92 | 93 | 		} | 
| 93 | 94 | 
 | 
| 94 |  | -		if !model.CustomSchedule.Recurring.OnMonthDay.IsNull() && !model.CustomSchedule.Recurring.OnMonthDay.IsUnknown() { | 
|  | 95 | +		if utils.IsKnown(model.CustomSchedule.Recurring.OnMonthDay) { | 
| 95 | 96 | 			var onMonthDay []float32 | 
| 96 | 97 | 			diags.Append(model.CustomSchedule.Recurring.OnMonthDay.ElementsAs(ctx, &onMonthDay, true)...) | 
| 97 | 98 | 			body.Schedule.Custom.Recurring.OnMonthDay = &onMonthDay | 
| @@ -162,14 +163,9 @@ func (model *MaintenanceWindowModel) fromAPIReadResponse(ctx context.Context, da | 
| 162 | 163 | func (model MaintenanceWindowModel) toAPIUpdateRequest(ctx context.Context) (kbapi.PatchMaintenanceWindowIdJSONRequestBody, diag.Diagnostics) { | 
| 163 | 164 | 	var diags = diag.Diagnostics{} | 
| 164 | 165 | 
 | 
| 165 |  | -	body := kbapi.PatchMaintenanceWindowIdJSONRequestBody{} | 
| 166 |  | - | 
| 167 |  | -	if !model.Enabled.IsNull() { | 
| 168 |  | -		body.Enabled = model.Enabled.ValueBoolPointer() | 
| 169 |  | -	} | 
| 170 |  | - | 
| 171 |  | -	if !model.Title.IsNull() { | 
| 172 |  | -		body.Title = model.Title.ValueStringPointer() | 
|  | 166 | +	body := kbapi.PatchMaintenanceWindowIdJSONRequestBody{ | 
|  | 167 | +		Enabled: model.Enabled.ValueBoolPointer(), | 
|  | 168 | +		Title:   model.Title.ValueStringPointer(), | 
| 173 | 169 | 	} | 
| 174 | 170 | 
 | 
| 175 | 171 | 	schedule := struct { | 
| @@ -207,7 +203,7 @@ func (model MaintenanceWindowModel) toAPIUpdateRequest(ctx context.Context) (kba | 
| 207 | 203 | 
 | 
| 208 | 204 | 	body.Schedule = &schedule | 
| 209 | 205 | 
 | 
| 210 |  | -	if !model.CustomSchedule.Timezone.IsNull() && !model.CustomSchedule.Timezone.IsUnknown() { | 
|  | 206 | +	if utils.IsKnown(model.CustomSchedule.Timezone) { | 
| 211 | 207 | 		body.Schedule.Custom.Timezone = model.CustomSchedule.Timezone.ValueStringPointer() | 
| 212 | 208 | 	} | 
| 213 | 209 | 
 | 
|  | 
0 commit comments