From 26cd5bf391eccd10c3a5c7eac5159312996bdf10 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Fri, 21 Dec 2018 16:18:06 -0800 Subject: [PATCH] [AutoPR hanaonazure/resource-manager] Add PATCH API example to hanaonazure (#3769) * Generated from b0d573e496f9e874b2747b5d52c52433330035a7 Add PATCH API example to hanaonazure * Generated from 8732e590abd1c05f1a5602a69f41cb0e379e4579 Add Tags definiton back * Generated from 256ea1929633c93a350f11a7eead3193688a8564 Change operationId to HanaInstances_Update --- .../hanaonazure/mgmt/hanaonazure/models.go | 1 + .../hanaonazure/hanainstances.go | 81 +++++++++++++++++++ .../hanaonazure/hanaonazureapi/interfaces.go | 1 + .../2017-11-03-preview/hanaonazure/models.go | 15 ++++ 4 files changed, 98 insertions(+) diff --git a/profiles/preview/preview/hanaonazure/mgmt/hanaonazure/models.go b/profiles/preview/preview/hanaonazure/mgmt/hanaonazure/models.go index c7f036e3a5dc..dbf59a944182 100644 --- a/profiles/preview/preview/hanaonazure/mgmt/hanaonazure/models.go +++ b/profiles/preview/preview/hanaonazure/mgmt/hanaonazure/models.go @@ -89,6 +89,7 @@ type OperationList = original.OperationList type OperationsClient = original.OperationsClient type Resource = original.Resource type StorageProfile = original.StorageProfile +type Tags = original.Tags func New(subscriptionID string) BaseClient { return original.New(subscriptionID) diff --git a/services/preview/hanaonazure/mgmt/2017-11-03-preview/hanaonazure/hanainstances.go b/services/preview/hanaonazure/mgmt/2017-11-03-preview/hanaonazure/hanainstances.go index eac79936b34f..a77751e56ab9 100644 --- a/services/preview/hanaonazure/mgmt/2017-11-03-preview/hanaonazure/hanainstances.go +++ b/services/preview/hanaonazure/mgmt/2017-11-03-preview/hanaonazure/hanainstances.go @@ -417,3 +417,84 @@ func (client HanaInstancesClient) RestartResponder(resp *http.Response) (result result.Response = resp return } + +// Update patches the Tags field of a SAP HANA instance for the specified subscription, resource group, and instance +// name. +// Parameters: +// resourceGroupName - name of the resource group. +// hanaInstanceName - name of the SAP HANA on Azure instance. +// tagsParameter - request body that only contains the new Tags field +func (client HanaInstancesClient) Update(ctx context.Context, resourceGroupName string, hanaInstanceName string, tagsParameter Tags) (result HanaInstance, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/HanaInstancesClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, hanaInstanceName, tagsParameter) + if err != nil { + err = autorest.NewErrorWithError(err, "hanaonazure.HanaInstancesClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "hanaonazure.HanaInstancesClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hanaonazure.HanaInstancesClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client HanaInstancesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, hanaInstanceName string, tagsParameter Tags) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "hanaInstanceName": autorest.Encode("path", hanaInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-11-03-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HanaOnAzure/hanaInstances/{hanaInstanceName}", pathParameters), + autorest.WithJSON(tagsParameter), + 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 HanaInstancesClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client HanaInstancesClient) UpdateResponder(resp *http.Response) (result HanaInstance, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/hanaonazure/mgmt/2017-11-03-preview/hanaonazure/hanaonazureapi/interfaces.go b/services/preview/hanaonazure/mgmt/2017-11-03-preview/hanaonazure/hanaonazureapi/interfaces.go index 85b274f5d369..98fe2147b536 100644 --- a/services/preview/hanaonazure/mgmt/2017-11-03-preview/hanaonazure/hanaonazureapi/interfaces.go +++ b/services/preview/hanaonazure/mgmt/2017-11-03-preview/hanaonazure/hanaonazureapi/interfaces.go @@ -36,6 +36,7 @@ type HanaInstancesClientAPI interface { List(ctx context.Context) (result hanaonazure.HanaInstancesListResultPage, err error) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result hanaonazure.HanaInstancesListResultPage, err error) Restart(ctx context.Context, resourceGroupName string, hanaInstanceName string) (result autorest.Response, err error) + Update(ctx context.Context, resourceGroupName string, hanaInstanceName string, tagsParameter hanaonazure.Tags) (result hanaonazure.HanaInstance, err error) } var _ HanaInstancesClientAPI = (*hanaonazure.HanaInstancesClient)(nil) diff --git a/services/preview/hanaonazure/mgmt/2017-11-03-preview/hanaonazure/models.go b/services/preview/hanaonazure/mgmt/2017-11-03-preview/hanaonazure/models.go index cc14ffc4ec98..04a44f88ef2c 100644 --- a/services/preview/hanaonazure/mgmt/2017-11-03-preview/hanaonazure/models.go +++ b/services/preview/hanaonazure/mgmt/2017-11-03-preview/hanaonazure/models.go @@ -507,3 +507,18 @@ type StorageProfile struct { // OsDisks - Specifies information about the operating system disk used by the hana instance. OsDisks *[]Disk `json:"osDisks,omitempty"` } + +// Tags tags field of the HANA instance. +type Tags struct { + // Tags - Tags field of the HANA instance. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for Tags. +func (t Tags) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if t.Tags != nil { + objectMap["tags"] = t.Tags + } + return json.Marshal(objectMap) +}