1package redisenterprise 2 3// Copyright (c) Microsoft Corporation. All rights reserved. 4// Licensed under the MIT License. See License.txt in the project root for license information. 5// 6// Code generated by Microsoft (R) AutoRest Code Generator. 7// Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 9import ( 10 "context" 11 "github.com/Azure/go-autorest/autorest" 12 "github.com/Azure/go-autorest/autorest/azure" 13 "github.com/Azure/go-autorest/tracing" 14 "net/http" 15) 16 17// GetClient is the REST API for managing Redis Enterprise resources in Azure. 18type GetClient struct { 19 BaseClient 20} 21 22// NewGetClient creates an instance of the GetClient client. 23func NewGetClient(subscriptionID string) GetClient { 24 return NewGetClientWithBaseURI(DefaultBaseURI, subscriptionID) 25} 26 27// NewGetClientWithBaseURI creates an instance of the GetClient client using a custom endpoint. Use this when 28// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 29func NewGetClientWithBaseURI(baseURI string, subscriptionID string) GetClient { 30 return GetClient{NewWithBaseURI(baseURI, subscriptionID)} 31} 32 33// OperationStatusMethod gets the status of operation. 34// Parameters: 35// location - the region the operation is in. 36// operationID - the operation's unique identifier. 37func (client GetClient) OperationStatusMethod(ctx context.Context, location string, operationID string) (result OperationStatus, err error) { 38 if tracing.IsEnabled() { 39 ctx = tracing.StartSpan(ctx, fqdn+"/GetClient.OperationStatusMethod") 40 defer func() { 41 sc := -1 42 if result.Response.Response != nil { 43 sc = result.Response.Response.StatusCode 44 } 45 tracing.EndSpan(ctx, sc, err) 46 }() 47 } 48 req, err := client.OperationStatusMethodPreparer(ctx, location, operationID) 49 if err != nil { 50 err = autorest.NewErrorWithError(err, "redisenterprise.GetClient", "OperationStatusMethod", nil, "Failure preparing request") 51 return 52 } 53 54 resp, err := client.OperationStatusMethodSender(req) 55 if err != nil { 56 result.Response = autorest.Response{Response: resp} 57 err = autorest.NewErrorWithError(err, "redisenterprise.GetClient", "OperationStatusMethod", resp, "Failure sending request") 58 return 59 } 60 61 result, err = client.OperationStatusMethodResponder(resp) 62 if err != nil { 63 err = autorest.NewErrorWithError(err, "redisenterprise.GetClient", "OperationStatusMethod", resp, "Failure responding to request") 64 return 65 } 66 67 return 68} 69 70// OperationStatusMethodPreparer prepares the OperationStatusMethod request. 71func (client GetClient) OperationStatusMethodPreparer(ctx context.Context, location string, operationID string) (*http.Request, error) { 72 pathParameters := map[string]interface{}{ 73 "location": autorest.Encode("path", location), 74 "operationId": autorest.Encode("path", operationID), 75 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 76 } 77 78 const APIVersion = "2020-10-01-preview" 79 queryParameters := map[string]interface{}{ 80 "api-version": APIVersion, 81 } 82 83 preparer := autorest.CreatePreparer( 84 autorest.AsGet(), 85 autorest.WithBaseURL(client.BaseURI), 86 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Cache/locations/{location}/operationsStatus/{operationId}", pathParameters), 87 autorest.WithQueryParameters(queryParameters)) 88 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 89} 90 91// OperationStatusMethodSender sends the OperationStatusMethod request. The method will close the 92// http.Response Body if it receives an error. 93func (client GetClient) OperationStatusMethodSender(req *http.Request) (*http.Response, error) { 94 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 95} 96 97// OperationStatusMethodResponder handles the response to the OperationStatusMethod request. The method always 98// closes the http.Response Body. 99func (client GetClient) OperationStatusMethodResponder(resp *http.Response) (result OperationStatus, err error) { 100 err = autorest.Respond( 101 resp, 102 azure.WithErrorUnlessStatusCode(http.StatusOK), 103 autorest.ByUnmarshallingJSON(&result), 104 autorest.ByClosing()) 105 result.Response = autorest.Response{Response: resp} 106 return 107} 108