Skip to content

Commit

Permalink
systemcentervirtualmachinemanager: refactoring to account for the b…
Browse files Browse the repository at this point in the history
…reaking changes in Azure/azure-rest-api-specs#26644
  • Loading branch information
tombuildsstuff committed Jun 4, 2024
1 parent 1ebfa9d commit 9a4c4b1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
},
Expand Down Expand Up @@ -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)
Expand All @@ -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)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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{}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
},
Expand Down Expand Up @@ -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),
}

Expand All @@ -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)
}

Expand Down

0 comments on commit 9a4c4b1

Please sign in to comment.