diff --git a/profiles/latest/compute/mgmt/compute/models.go b/profiles/latest/compute/mgmt/compute/models.go index e089fec5cee5..af120f14e85c 100644 --- a/profiles/latest/compute/mgmt/compute/models.go +++ b/profiles/latest/compute/mgmt/compute/models.go @@ -991,9 +991,11 @@ type VirtualMachineScaleSetExtensionListResultIterator = original.VirtualMachine type VirtualMachineScaleSetExtensionListResultPage = original.VirtualMachineScaleSetExtensionListResultPage type VirtualMachineScaleSetExtensionProfile = original.VirtualMachineScaleSetExtensionProfile type VirtualMachineScaleSetExtensionProperties = original.VirtualMachineScaleSetExtensionProperties +type VirtualMachineScaleSetExtensionUpdate = original.VirtualMachineScaleSetExtensionUpdate type VirtualMachineScaleSetExtensionsClient = original.VirtualMachineScaleSetExtensionsClient type VirtualMachineScaleSetExtensionsCreateOrUpdateFuture = original.VirtualMachineScaleSetExtensionsCreateOrUpdateFuture type VirtualMachineScaleSetExtensionsDeleteFuture = original.VirtualMachineScaleSetExtensionsDeleteFuture +type VirtualMachineScaleSetExtensionsUpdateFuture = original.VirtualMachineScaleSetExtensionsUpdateFuture type VirtualMachineScaleSetIPConfiguration = original.VirtualMachineScaleSetIPConfiguration type VirtualMachineScaleSetIPConfigurationProperties = original.VirtualMachineScaleSetIPConfigurationProperties type VirtualMachineScaleSetIPTag = original.VirtualMachineScaleSetIPTag diff --git a/profiles/preview/compute/mgmt/compute/models.go b/profiles/preview/compute/mgmt/compute/models.go index f187e0d0536c..7f529528affb 100644 --- a/profiles/preview/compute/mgmt/compute/models.go +++ b/profiles/preview/compute/mgmt/compute/models.go @@ -991,9 +991,11 @@ type VirtualMachineScaleSetExtensionListResultIterator = original.VirtualMachine type VirtualMachineScaleSetExtensionListResultPage = original.VirtualMachineScaleSetExtensionListResultPage type VirtualMachineScaleSetExtensionProfile = original.VirtualMachineScaleSetExtensionProfile type VirtualMachineScaleSetExtensionProperties = original.VirtualMachineScaleSetExtensionProperties +type VirtualMachineScaleSetExtensionUpdate = original.VirtualMachineScaleSetExtensionUpdate type VirtualMachineScaleSetExtensionsClient = original.VirtualMachineScaleSetExtensionsClient type VirtualMachineScaleSetExtensionsCreateOrUpdateFuture = original.VirtualMachineScaleSetExtensionsCreateOrUpdateFuture type VirtualMachineScaleSetExtensionsDeleteFuture = original.VirtualMachineScaleSetExtensionsDeleteFuture +type VirtualMachineScaleSetExtensionsUpdateFuture = original.VirtualMachineScaleSetExtensionsUpdateFuture type VirtualMachineScaleSetIPConfiguration = original.VirtualMachineScaleSetIPConfiguration type VirtualMachineScaleSetIPConfigurationProperties = original.VirtualMachineScaleSetIPConfigurationProperties type VirtualMachineScaleSetIPTag = original.VirtualMachineScaleSetIPTag diff --git a/services/compute/mgmt/2019-07-01/compute/computeapi/interfaces.go b/services/compute/mgmt/2019-07-01/compute/computeapi/interfaces.go index e5e0b27d586c..9cb805379b62 100644 --- a/services/compute/mgmt/2019-07-01/compute/computeapi/interfaces.go +++ b/services/compute/mgmt/2019-07-01/compute/computeapi/interfaces.go @@ -195,6 +195,7 @@ type VirtualMachineScaleSetExtensionsClientAPI interface { Delete(ctx context.Context, resourceGroupName string, VMScaleSetName string, vmssExtensionName string) (result compute.VirtualMachineScaleSetExtensionsDeleteFuture, err error) Get(ctx context.Context, resourceGroupName string, VMScaleSetName string, vmssExtensionName string, expand string) (result compute.VirtualMachineScaleSetExtension, err error) List(ctx context.Context, resourceGroupName string, VMScaleSetName string) (result compute.VirtualMachineScaleSetExtensionListResultPage, err error) + Update(ctx context.Context, resourceGroupName string, VMScaleSetName string, vmssExtensionName string, extensionParameters compute.VirtualMachineScaleSetExtensionUpdate) (result compute.VirtualMachineScaleSetExtensionsUpdateFuture, err error) } var _ VirtualMachineScaleSetExtensionsClientAPI = (*compute.VirtualMachineScaleSetExtensionsClient)(nil) diff --git a/services/compute/mgmt/2019-07-01/compute/models.go b/services/compute/mgmt/2019-07-01/compute/models.go index 3b1f20a9f5d2..ea09b2c85993 100644 --- a/services/compute/mgmt/2019-07-01/compute/models.go +++ b/services/compute/mgmt/2019-07-01/compute/models.go @@ -10482,7 +10482,9 @@ type VirtualMachineScaleSetDataDisk struct { type VirtualMachineScaleSetExtension struct { autorest.Response `json:"-"` // Name - The name of the extension. - Name *string `json:"name,omitempty"` + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` *VirtualMachineScaleSetExtensionProperties `json:"properties,omitempty"` // ID - READ-ONLY; Resource Id ID *string `json:"id,omitempty"` @@ -10518,6 +10520,15 @@ func (vmsse *VirtualMachineScaleSetExtension) UnmarshalJSON(body []byte) error { } vmsse.Name = &name } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + vmsse.Type = &typeVar + } case "properties": if v != nil { var virtualMachineScaleSetExtensionProperties VirtualMachineScaleSetExtensionProperties @@ -10770,6 +10781,106 @@ func (future *VirtualMachineScaleSetExtensionsDeleteFuture) Result(client Virtua return } +// VirtualMachineScaleSetExtensionsUpdateFuture an abstraction for monitoring and retrieving the results of +// a long-running operation. +type VirtualMachineScaleSetExtensionsUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *VirtualMachineScaleSetExtensionsUpdateFuture) Result(client VirtualMachineScaleSetExtensionsClient) (vmsse VirtualMachineScaleSetExtension, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetExtensionsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("compute.VirtualMachineScaleSetExtensionsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if vmsse.Response.Response, err = future.GetResult(sender); err == nil && vmsse.Response.Response.StatusCode != http.StatusNoContent { + vmsse, err = client.UpdateResponder(vmsse.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetExtensionsUpdateFuture", "Result", vmsse.Response.Response, "Failure responding to request") + } + } + return +} + +// VirtualMachineScaleSetExtensionUpdate describes a Virtual Machine Scale Set Extension. +type VirtualMachineScaleSetExtensionUpdate struct { + // Name - READ-ONLY; The name of the extension. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + *VirtualMachineScaleSetExtensionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` +} + +// MarshalJSON is the custom marshaler for VirtualMachineScaleSetExtensionUpdate. +func (vmsseu VirtualMachineScaleSetExtensionUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if vmsseu.VirtualMachineScaleSetExtensionProperties != nil { + objectMap["properties"] = vmsseu.VirtualMachineScaleSetExtensionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for VirtualMachineScaleSetExtensionUpdate struct. +func (vmsseu *VirtualMachineScaleSetExtensionUpdate) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + vmsseu.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + vmsseu.Type = &typeVar + } + case "properties": + if v != nil { + var virtualMachineScaleSetExtensionProperties VirtualMachineScaleSetExtensionProperties + err = json.Unmarshal(*v, &virtualMachineScaleSetExtensionProperties) + if err != nil { + return err + } + vmsseu.VirtualMachineScaleSetExtensionProperties = &virtualMachineScaleSetExtensionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + vmsseu.ID = &ID + } + } + } + + return nil +} + // VirtualMachineScaleSetIdentity identity for the virtual machine scale set. type VirtualMachineScaleSetIdentity struct { // PrincipalID - READ-ONLY; The principal id of virtual machine scale set identity. This property will only be provided for a system assigned identity. diff --git a/services/compute/mgmt/2019-07-01/compute/virtualmachines.go b/services/compute/mgmt/2019-07-01/compute/virtualmachines.go index b329db181d98..3d25da43d3ea 100644 --- a/services/compute/mgmt/2019-07-01/compute/virtualmachines.go +++ b/services/compute/mgmt/2019-07-01/compute/virtualmachines.go @@ -462,7 +462,8 @@ func (client VirtualMachinesClient) DeleteResponder(resp *http.Response) (result return } -// Generalize sets the state of the virtual machine to generalized. +// Generalize sets the OS state of the virtual machine to generalized. It is recommended to sysprep the virtual machine +// before performing this operation // Parameters: // resourceGroupName - the name of the resource group. // VMName - the name of the virtual machine. diff --git a/services/compute/mgmt/2019-07-01/compute/virtualmachinescalesetextensions.go b/services/compute/mgmt/2019-07-01/compute/virtualmachinescalesetextensions.go index 7e4d6d0a6b70..54d16ac72156 100644 --- a/services/compute/mgmt/2019-07-01/compute/virtualmachinescalesetextensions.go +++ b/services/compute/mgmt/2019-07-01/compute/virtualmachinescalesetextensions.go @@ -87,6 +87,7 @@ func (client VirtualMachineScaleSetExtensionsClient) CreateOrUpdatePreparer(ctx "api-version": APIVersion, } + extensionParameters.Type = nil preparer := autorest.CreatePreparer( autorest.AsContentType("application/json; charset=utf-8"), autorest.AsPut(), @@ -398,3 +399,87 @@ func (client VirtualMachineScaleSetExtensionsClient) ListComplete(ctx context.Co result.page, err = client.List(ctx, resourceGroupName, VMScaleSetName) return } + +// Update the operation to update an extension. +// Parameters: +// resourceGroupName - the name of the resource group. +// VMScaleSetName - the name of the VM scale set where the extension should be updated. +// vmssExtensionName - the name of the VM scale set extension. +// extensionParameters - parameters supplied to the Update VM scale set Extension operation. +func (client VirtualMachineScaleSetExtensionsClient) Update(ctx context.Context, resourceGroupName string, VMScaleSetName string, vmssExtensionName string, extensionParameters VirtualMachineScaleSetExtensionUpdate) (result VirtualMachineScaleSetExtensionsUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineScaleSetExtensionsClient.Update") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, VMScaleSetName, vmssExtensionName, extensionParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetExtensionsClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetExtensionsClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client VirtualMachineScaleSetExtensionsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, VMScaleSetName string, vmssExtensionName string, extensionParameters VirtualMachineScaleSetExtensionUpdate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmScaleSetName": autorest.Encode("path", VMScaleSetName), + "vmssExtensionName": autorest.Encode("path", vmssExtensionName), + } + + const APIVersion = "2019-07-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + extensionParameters.Name = nil + extensionParameters.Type = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}", pathParameters), + autorest.WithJSON(extensionParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualMachineScaleSetExtensionsClient) UpdateSender(req *http.Request) (future VirtualMachineScaleSetExtensionsUpdateFuture, err error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, sd...) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client VirtualMachineScaleSetExtensionsClient) UpdateResponder(resp *http.Response) (result VirtualMachineScaleSetExtension, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +}