...

Source file src/github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2016-06-01/backup/protecteditemoperationstatuses.go

Documentation: github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2016-06-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  // ProtectedItemOperationStatusesClient is the open API 2.0 Specs for Azure RecoveryServices Backup service
    18  type ProtectedItemOperationStatusesClient struct {
    19  	BaseClient
    20  }
    21  
    22  // NewProtectedItemOperationStatusesClient creates an instance of the ProtectedItemOperationStatusesClient client.
    23  func NewProtectedItemOperationStatusesClient(subscriptionID string) ProtectedItemOperationStatusesClient {
    24  	return NewProtectedItemOperationStatusesClientWithBaseURI(DefaultBaseURI, subscriptionID)
    25  }
    26  
    27  // NewProtectedItemOperationStatusesClientWithBaseURI creates an instance of the ProtectedItemOperationStatusesClient
    28  // client using a custom endpoint.  Use this when interacting with an Azure cloud that uses a non-standard base URI
    29  // (sovereign clouds, Azure stack).
    30  func NewProtectedItemOperationStatusesClientWithBaseURI(baseURI string, subscriptionID string) ProtectedItemOperationStatusesClient {
    31  	return ProtectedItemOperationStatusesClient{NewWithBaseURI(baseURI, subscriptionID)}
    32  }
    33  
    34  // Get gets the status of an operation such as triggering a backup or restore. The status can be: In progress,
    35  // Completed, or Failed. You can refer to the OperationStatus enum for all the possible states of the operation. Some
    36  // operations create jobs. This method returns the list of jobs associated with the operation.
    37  // Parameters:
    38  // vaultName - the name of the Recovery Services vault.
    39  // resourceGroupName - the name of the resource group associated with the Recovery Services vault.
    40  // fabricName - the fabric name associated with the backup item.
    41  // containerName - the container name associated with the backup item.
    42  // protectedItemName - the name of backup item used in this GET operation.
    43  // operationID - the OperationID used in this GET operation.
    44  func (client ProtectedItemOperationStatusesClient) Get(ctx context.Context, vaultName string, resourceGroupName string, fabricName string, containerName string, protectedItemName string, operationID string) (result OperationStatus, err error) {
    45  	if tracing.IsEnabled() {
    46  		ctx = tracing.StartSpan(ctx, fqdn+"/ProtectedItemOperationStatusesClient.Get")
    47  		defer func() {
    48  			sc := -1
    49  			if result.Response.Response != nil {
    50  				sc = result.Response.Response.StatusCode
    51  			}
    52  			tracing.EndSpan(ctx, sc, err)
    53  		}()
    54  	}
    55  	req, err := client.GetPreparer(ctx, vaultName, resourceGroupName, fabricName, containerName, protectedItemName, operationID)
    56  	if err != nil {
    57  		err = autorest.NewErrorWithError(err, "backup.ProtectedItemOperationStatusesClient", "Get", nil, "Failure preparing request")
    58  		return
    59  	}
    60  
    61  	resp, err := client.GetSender(req)
    62  	if err != nil {
    63  		result.Response = autorest.Response{Response: resp}
    64  		err = autorest.NewErrorWithError(err, "backup.ProtectedItemOperationStatusesClient", "Get", resp, "Failure sending request")
    65  		return
    66  	}
    67  
    68  	result, err = client.GetResponder(resp)
    69  	if err != nil {
    70  		err = autorest.NewErrorWithError(err, "backup.ProtectedItemOperationStatusesClient", "Get", resp, "Failure responding to request")
    71  		return
    72  	}
    73  
    74  	return
    75  }
    76  
    77  // GetPreparer prepares the Get request.
    78  func (client ProtectedItemOperationStatusesClient) GetPreparer(ctx context.Context, vaultName string, resourceGroupName string, fabricName string, containerName string, protectedItemName string, operationID string) (*http.Request, error) {
    79  	pathParameters := map[string]interface{}{
    80  		"containerName":     autorest.Encode("path", containerName),
    81  		"fabricName":        autorest.Encode("path", fabricName),
    82  		"operationId":       autorest.Encode("path", operationID),
    83  		"protectedItemName": autorest.Encode("path", protectedItemName),
    84  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
    85  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
    86  		"vaultName":         autorest.Encode("path", vaultName),
    87  	}
    88  
    89  	const APIVersion = "2016-06-01"
    90  	queryParameters := map[string]interface{}{
    91  		"api-version": APIVersion,
    92  	}
    93  
    94  	preparer := autorest.CreatePreparer(
    95  		autorest.AsGet(),
    96  		autorest.WithBaseURL(client.BaseURI),
    97  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupFabrics/{fabricName}/protectionContainers/{containerName}/protectedItems/{protectedItemName}/operationsStatus/{operationId}", pathParameters),
    98  		autorest.WithQueryParameters(queryParameters))
    99  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   100  }
   101  
   102  // GetSender sends the Get request. The method will close the
   103  // http.Response Body if it receives an error.
   104  func (client ProtectedItemOperationStatusesClient) GetSender(req *http.Request) (*http.Response, error) {
   105  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   106  }
   107  
   108  // GetResponder handles the response to the Get request. The method always
   109  // closes the http.Response Body.
   110  func (client ProtectedItemOperationStatusesClient) GetResponder(resp *http.Response) (result OperationStatus, err error) {
   111  	err = autorest.Respond(
   112  		resp,
   113  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   114  		autorest.ByUnmarshallingJSON(&result),
   115  		autorest.ByClosing())
   116  	result.Response = autorest.Response{Response: resp}
   117  	return
   118  }
   119  

View as plain text