From a2d7e1571e9e077e76c8c1d30cc17aed24fba5ec Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Tue, 15 Jan 2019 13:36:24 -0800 Subject: [PATCH] Generated from 83397435bb3aed745b66ea04152081ea7684592b (#3878) Changed hana instance restart to be async --- .../hanaonazure/mgmt/hanaonazure/models.go | 1 + .../hanaonazure/hanainstances.go | 26 +++++++++---------- .../hanaonazure/hanaonazureapi/interfaces.go | 3 +-- .../2017-11-03-preview/hanaonazure/models.go | 24 +++++++++++++++++ 4 files changed, 39 insertions(+), 15 deletions(-) diff --git a/profiles/preview/preview/hanaonazure/mgmt/hanaonazure/models.go b/profiles/preview/preview/hanaonazure/mgmt/hanaonazure/models.go index dbf59a944182..874b9a9794f4 100644 --- a/profiles/preview/preview/hanaonazure/mgmt/hanaonazure/models.go +++ b/profiles/preview/preview/hanaonazure/mgmt/hanaonazure/models.go @@ -80,6 +80,7 @@ type HanaInstancesClient = original.HanaInstancesClient type HanaInstancesListResult = original.HanaInstancesListResult type HanaInstancesListResultIterator = original.HanaInstancesListResultIterator type HanaInstancesListResultPage = original.HanaInstancesListResultPage +type HanaInstancesRestartFuture = original.HanaInstancesRestartFuture type HardwareProfile = original.HardwareProfile type IPAddress = original.IPAddress type NetworkProfile = original.NetworkProfile 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 a77751e56ab9..f8f903d6d226 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 @@ -346,13 +346,13 @@ func (client HanaInstancesClient) ListByResourceGroupComplete(ctx context.Contex // Parameters: // resourceGroupName - name of the resource group. // hanaInstanceName - name of the SAP HANA on Azure instance. -func (client HanaInstancesClient) Restart(ctx context.Context, resourceGroupName string, hanaInstanceName string) (result autorest.Response, err error) { +func (client HanaInstancesClient) Restart(ctx context.Context, resourceGroupName string, hanaInstanceName string) (result HanaInstancesRestartFuture, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/HanaInstancesClient.Restart") defer func() { sc := -1 - if result.Response != nil { - sc = result.Response.StatusCode + if result.Response() != nil { + sc = result.Response().StatusCode } tracing.EndSpan(ctx, sc, err) }() @@ -363,18 +363,12 @@ func (client HanaInstancesClient) Restart(ctx context.Context, resourceGroupName return } - resp, err := client.RestartSender(req) + result, err = client.RestartSender(req) if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "hanaonazure.HanaInstancesClient", "Restart", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "hanaonazure.HanaInstancesClient", "Restart", result.Response(), "Failure sending request") return } - result, err = client.RestartResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "hanaonazure.HanaInstancesClient", "Restart", resp, "Failure responding to request") - } - return } @@ -401,9 +395,15 @@ func (client HanaInstancesClient) RestartPreparer(ctx context.Context, resourceG // RestartSender sends the Restart request. The method will close the // http.Response Body if it receives an error. -func (client HanaInstancesClient) RestartSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, +func (client HanaInstancesClient) RestartSender(req *http.Request) (future HanaInstancesRestartFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return } // RestartResponder handles the response to the Restart request. The method always 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 98fe2147b536..137f12e115b5 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 @@ -20,7 +20,6 @@ package hanaonazureapi import ( "context" "github.com/Azure/azure-sdk-for-go/services/preview/hanaonazure/mgmt/2017-11-03-preview/hanaonazure" - "github.com/Azure/go-autorest/autorest" ) // OperationsClientAPI contains the set of methods on the OperationsClient type. @@ -35,7 +34,7 @@ type HanaInstancesClientAPI interface { Get(ctx context.Context, resourceGroupName string, hanaInstanceName string) (result hanaonazure.HanaInstance, err error) 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) + Restart(ctx context.Context, resourceGroupName string, hanaInstanceName string) (result hanaonazure.HanaInstancesRestartFuture, err error) Update(ctx context.Context, resourceGroupName string, hanaInstanceName string, tagsParameter hanaonazure.Tags) (result hanaonazure.HanaInstance, err error) } 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 04a44f88ef2c..4de682b8cfa7 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 @@ -21,6 +21,7 @@ import ( "context" "encoding/json" "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" "github.com/Azure/go-autorest/autorest/to" "github.com/Azure/go-autorest/tracing" "net/http" @@ -418,6 +419,29 @@ func NewHanaInstancesListResultPage(getNextPage func(context.Context, HanaInstan return HanaInstancesListResultPage{fn: getNextPage} } +// HanaInstancesRestartFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type HanaInstancesRestartFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *HanaInstancesRestartFuture) Result(client HanaInstancesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "hanaonazure.HanaInstancesRestartFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("hanaonazure.HanaInstancesRestartFuture") + return + } + ar.Response = future.Response() + return +} + // HardwareProfile specifies the hardware settings for the HANA instance. type HardwareProfile struct { // HardwareType - Name of the hardware type (vendor and/or their product name). Possible values include: 'CiscoUCS', 'HPE'