Skip to content

Commit

Permalink
chore: update image optimization field on create (#169)
Browse files Browse the repository at this point in the history
* chore: update image optimization field on create

* chore: include updated fields in response structure
  • Loading branch information
PatrickMenoti authored Dec 20, 2024
1 parent 2a3124d commit c705f9d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions internal/resource_edge_application_main_setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,12 @@ func (r *edgeApplicationResource) Create(ctx context.Context, req resource.Creat
requestUpdate.DeviceDetection = plan.EdgeApplication.DeviceDetection.ValueBoolPointer()
}

if plan.EdgeApplication.ImageOptimization.ValueBool() {
requestUpdate.ImageOptimization = plan.EdgeApplication.ImageOptimization.ValueBoolPointer()
}

ID := strconv.Itoa(int(createEdgeApplication.Results.GetId()))

updateEdgeApplication, response, err := r.client.edgeApplicationsApi.
EdgeApplicationsMainSettingsAPI.
EdgeApplicationsIdPatch(ctx, ID).
Expand Down Expand Up @@ -307,9 +312,7 @@ func (r *edgeApplicationResource) Create(ctx context.Context, req resource.Creat
HTTP3: types.BoolValue(createEdgeApplication.Results.GetHttp3()),
SupportedCiphers: types.StringValue(createEdgeApplication.Results.GetSupportedCiphers()),
Caching: types.BoolValue(createEdgeApplication.Results.GetCaching()),
DeviceDetection: types.BoolValue(createEdgeApplication.Results.GetDeviceDetection()),
EdgeFirewall: types.BoolValue(createEdgeApplication.Results.GetEdgeFirewall()),
ImageOptimization: types.BoolValue(createEdgeApplication.Results.GetImageOptimization()),
RawLogs: types.BoolValue(createEdgeApplication.Results.GetRawLogs()),
WebApplicationFirewall: types.BoolValue(createEdgeApplication.Results.GetWebApplicationFirewall()),
}
Expand Down Expand Up @@ -344,6 +347,12 @@ func (r *edgeApplicationResource) Create(ctx context.Context, req resource.Creat
edgeAppResults.DeviceDetection = types.BoolValue(updateEdgeApplication.Results.GetDeviceDetection())
}

if requestUpdate.ImageOptimization == nil {
edgeAppResults.ImageOptimization = types.BoolValue(createEdgeApplication.Results.GetImageOptimization())
} else {
edgeAppResults.ImageOptimization = types.BoolValue(updateEdgeApplication.Results.GetImageOptimization())
}

plan.EdgeApplication = edgeAppResults
plan.SchemaVersion = types.Int64Value(createEdgeApplication.SchemaVersion)
plan.ID = types.StringValue(strconv.FormatInt(createEdgeApplication.Results.Id, 10))
Expand Down

0 comments on commit c705f9d

Please sign in to comment.