From 9a4c4b168f23b8dd81e79307781295d55482aa57 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Tue, 4 Jun 2024 18:27:27 +0200 Subject: [PATCH] `systemcentervirtualmachinemanager`: refactoring to account for the breaking changes in https://github.com/Azure/azure-rest-api-specs/pull/26644 --- ...ual_machine_manager_availability_set_resource.go | 8 +++++--- ...l_machine_manager_inventory_items_data_source.go | 13 +++++-------- ...enter_virtual_machine_manager_server_resource.go | 12 +++++++----- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/internal/services/systemcentervirtualmachinemanager/system_center_virtual_machine_manager_availability_set_resource.go b/internal/services/systemcentervirtualmachinemanager/system_center_virtual_machine_manager_availability_set_resource.go index 262befa93717..bc75c33ad056 100644 --- a/internal/services/systemcentervirtualmachinemanager/system_center_virtual_machine_manager_availability_set_resource.go +++ b/internal/services/systemcentervirtualmachinemanager/system_center_virtual_machine_manager_availability_set_resource.go @@ -107,7 +107,7 @@ func (r SystemCenterVirtualMachineManagerAvailabilitySetResource) Create() sdk.R Type: utils.String("customLocation"), Name: utils.String(model.CustomLocationId), }, - Properties: availabilitysets.AvailabilitySetProperties{ + Properties: &availabilitysets.AvailabilitySetProperties{ AvailabilitySetName: utils.String(id.AvailabilitySetName), VMmServerId: utils.String(scvmmServerId.ID()), }, @@ -179,7 +179,7 @@ func (r SystemCenterVirtualMachineManagerAvailabilitySetResource) Update() sdk.R return fmt.Errorf("decoding: %+v", err) } - parameters := availabilitysets.ResourcePatch{} + parameters := availabilitysets.AvailabilitySetTagsUpdate{} if metadata.ResourceData.HasChange("tags") { parameters.Tags = pointer.To(model.Tags) @@ -205,7 +205,9 @@ func (r SystemCenterVirtualMachineManagerAvailabilitySetResource) Delete() sdk.R return err } - if err := client.DeleteThenPoll(ctx, *id, availabilitysets.DeleteOperationOptions{Force: pointer.To(availabilitysets.ForceTrue)}); err != nil { + opts := availabilitysets.DefaultDeleteOperationOptions() + opts.Force = pointer.To(availabilitysets.ForceDeleteTrue) + if err := client.DeleteThenPoll(ctx, *id, opts); err != nil { return fmt.Errorf("deleting %s: %+v", *id, err) } diff --git a/internal/services/systemcentervirtualmachinemanager/system_center_virtual_machine_manager_inventory_items_data_source.go b/internal/services/systemcentervirtualmachinemanager/system_center_virtual_machine_manager_inventory_items_data_source.go index 742133c1efdd..97a4f6967790 100644 --- a/internal/services/systemcentervirtualmachinemanager/system_center_virtual_machine_manager_inventory_items_data_source.go +++ b/internal/services/systemcentervirtualmachinemanager/system_center_virtual_machine_manager_inventory_items_data_source.go @@ -98,15 +98,15 @@ func (l SystemCenterVirtualMachineManagerInventoryItemsDataSource) Read() sdk.Re return err } - resp, err := client.ListByVMMServer(ctx, *scvmmServerId) + resp, err := client.ListByVMmServerComplete(ctx, *scvmmServerId) if err != nil { - if response.WasNotFound(resp.HttpResponse) { + if response.WasNotFound(resp.LatestHttpResponse) { return fmt.Errorf("%s was not found", scvmmServerId) } return fmt.Errorf("reading %s: %+v", scvmmServerId, err) } - if model := resp.Model; model != nil { + if model := resp.Items; model != nil { inventoryItems, err := flattenInventoryItems(model, state.InventoryType) if err != nil { return err @@ -124,13 +124,10 @@ func (l SystemCenterVirtualMachineManagerInventoryItemsDataSource) Read() sdk.Re } } -func flattenInventoryItems(input *[]inventoryitems.InventoryItem, inventoryType string) (*[]InventoryItem, error) { +func flattenInventoryItems(input []inventoryitems.InventoryItem, inventoryType string) (*[]InventoryItem, error) { results := make([]InventoryItem, 0) - if input == nil { - return &results, nil - } - for _, item := range *input { + for _, item := range input { if props := item.Properties; props != nil { inventoryItem := InventoryItem{} diff --git a/internal/services/systemcentervirtualmachinemanager/system_center_virtual_machine_manager_server_resource.go b/internal/services/systemcentervirtualmachinemanager/system_center_virtual_machine_manager_server_resource.go index 9c57f2d7c170..10afeec993a2 100644 --- a/internal/services/systemcentervirtualmachinemanager/system_center_virtual_machine_manager_server_resource.go +++ b/internal/services/systemcentervirtualmachinemanager/system_center_virtual_machine_manager_server_resource.go @@ -125,14 +125,14 @@ func (r SystemCenterVirtualMachineManagerServerResource) Create() sdk.ResourceFu return metadata.ResourceRequiresImport(r.ResourceType(), id) } - parameters := &vmmservers.VMMServer{ + parameters := &vmmservers.VMmServer{ Location: location.Normalize(model.Location), ExtendedLocation: vmmservers.ExtendedLocation{ Type: pointer.To("customLocation"), Name: pointer.To(model.CustomLocationId), }, - Properties: vmmservers.VMMServerProperties{ - Credentials: &vmmservers.VMMCredential{ + Properties: &vmmservers.VMmServerProperties{ + Credentials: &vmmservers.VMmCredential{ Username: pointer.To(model.Username), Password: pointer.To(model.Password), }, @@ -212,7 +212,7 @@ func (r SystemCenterVirtualMachineManagerServerResource) Update() sdk.ResourceFu return fmt.Errorf("decoding: %+v", err) } - parameters := vmmservers.ResourcePatch{ + parameters := vmmservers.VMmServerTagsUpdate{ Tags: pointer.To(model.Tags), } @@ -236,7 +236,9 @@ func (r SystemCenterVirtualMachineManagerServerResource) Delete() sdk.ResourceFu return err } - if err := client.DeleteThenPoll(ctx, *id, vmmservers.DeleteOperationOptions{Force: pointer.To(vmmservers.ForceTrue)}); err != nil { + opts := vmmservers.DefaultDeleteOperationOptions() + opts.Force = pointer.To(vmmservers.ForceDeleteTrue) + if err := client.DeleteThenPoll(ctx, *id, opts); err != nil { return fmt.Errorf("deleting %s: %+v", *id, err) }