...

Source file src/github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2021-07-01/backup/status.go

Documentation: github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2021-07-01/backup

     1  package backup
     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  
     9  import (
    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  // StatusClient is the open API 2.0 Specs for Azure RecoveryServices Backup service
    18  type StatusClient struct {
    19  	BaseClient
    20  }
    21  
    22  // NewStatusClient creates an instance of the StatusClient client.
    23  func NewStatusClient(subscriptionID string) StatusClient {
    24  	return NewStatusClientWithBaseURI(DefaultBaseURI, subscriptionID)
    25  }
    26  
    27  // NewStatusClientWithBaseURI creates an instance of the StatusClient 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).
    29  func NewStatusClientWithBaseURI(baseURI string, subscriptionID string) StatusClient {
    30  	return StatusClient{NewWithBaseURI(baseURI, subscriptionID)}
    31  }
    32  
    33  // Get sends the get request.
    34  // Parameters:
    35  // azureRegion - azure region to hit Api
    36  // parameters - container Backup Status Request
    37  func (client StatusClient) Get(ctx context.Context, azureRegion string, parameters StatusRequest) (result StatusResponse, err error) {
    38  	if tracing.IsEnabled() {
    39  		ctx = tracing.StartSpan(ctx, fqdn+"/StatusClient.Get")
    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.GetPreparer(ctx, azureRegion, parameters)
    49  	if err != nil {
    50  		err = autorest.NewErrorWithError(err, "backup.StatusClient", "Get", nil, "Failure preparing request")
    51  		return
    52  	}
    53  
    54  	resp, err := client.GetSender(req)
    55  	if err != nil {
    56  		result.Response = autorest.Response{Response: resp}
    57  		err = autorest.NewErrorWithError(err, "backup.StatusClient", "Get", resp, "Failure sending request")
    58  		return
    59  	}
    60  
    61  	result, err = client.GetResponder(resp)
    62  	if err != nil {
    63  		err = autorest.NewErrorWithError(err, "backup.StatusClient", "Get", resp, "Failure responding to request")
    64  		return
    65  	}
    66  
    67  	return
    68  }
    69  
    70  // GetPreparer prepares the Get request.
    71  func (client StatusClient) GetPreparer(ctx context.Context, azureRegion string, parameters StatusRequest) (*http.Request, error) {
    72  	pathParameters := map[string]interface{}{
    73  		"azureRegion":    autorest.Encode("path", azureRegion),
    74  		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
    75  	}
    76  
    77  	const APIVersion = "2021-07-01"
    78  	queryParameters := map[string]interface{}{
    79  		"api-version": APIVersion,
    80  	}
    81  
    82  	preparer := autorest.CreatePreparer(
    83  		autorest.AsContentType("application/json; charset=utf-8"),
    84  		autorest.AsPost(),
    85  		autorest.WithBaseURL(client.BaseURI),
    86  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/providers/Microsoft.RecoveryServices/locations/{azureRegion}/backupStatus", pathParameters),
    87  		autorest.WithJSON(parameters),
    88  		autorest.WithQueryParameters(queryParameters))
    89  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    90  }
    91  
    92  // GetSender sends the Get request. The method will close the
    93  // http.Response Body if it receives an error.
    94  func (client StatusClient) GetSender(req *http.Request) (*http.Response, error) {
    95  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
    96  }
    97  
    98  // GetResponder handles the response to the Get request. The method always
    99  // closes the http.Response Body.
   100  func (client StatusClient) GetResponder(resp *http.Response) (result StatusResponse, err error) {
   101  	err = autorest.Respond(
   102  		resp,
   103  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   104  		autorest.ByUnmarshallingJSON(&result),
   105  		autorest.ByClosing())
   106  	result.Response = autorest.Response{Response: resp}
   107  	return
   108  }
   109  

View as plain text