...

Source file src/github.com/Azure/azure-sdk-for-go/services/mediaservices/mgmt/2021-11-01/media/operationstatuses.go

Documentation: github.com/Azure/azure-sdk-for-go/services/mediaservices/mgmt/2021-11-01/media

     1  package media
     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  // OperationStatusesClient is the client for the OperationStatuses methods of the Media service.
    18  type OperationStatusesClient struct {
    19  	BaseClient
    20  }
    21  
    22  // NewOperationStatusesClient creates an instance of the OperationStatusesClient client.
    23  func NewOperationStatusesClient(subscriptionID string) OperationStatusesClient {
    24  	return NewOperationStatusesClientWithBaseURI(DefaultBaseURI, subscriptionID)
    25  }
    26  
    27  // NewOperationStatusesClientWithBaseURI creates an instance of the OperationStatusesClient client using a custom
    28  // endpoint.  Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure
    29  // stack).
    30  func NewOperationStatusesClientWithBaseURI(baseURI string, subscriptionID string) OperationStatusesClient {
    31  	return OperationStatusesClient{NewWithBaseURI(baseURI, subscriptionID)}
    32  }
    33  
    34  // Get get asset track operation status.
    35  // Parameters:
    36  // resourceGroupName - the name of the resource group within the Azure subscription.
    37  // accountName - the Media Services account name.
    38  // assetName - the Asset name.
    39  // trackName - the Asset Track name.
    40  // operationID - operation Id.
    41  func (client OperationStatusesClient) Get(ctx context.Context, resourceGroupName string, accountName string, assetName string, trackName string, operationID string) (result AssetTrackOperationStatus, err error) {
    42  	if tracing.IsEnabled() {
    43  		ctx = tracing.StartSpan(ctx, fqdn+"/OperationStatusesClient.Get")
    44  		defer func() {
    45  			sc := -1
    46  			if result.Response.Response != nil {
    47  				sc = result.Response.Response.StatusCode
    48  			}
    49  			tracing.EndSpan(ctx, sc, err)
    50  		}()
    51  	}
    52  	req, err := client.GetPreparer(ctx, resourceGroupName, accountName, assetName, trackName, operationID)
    53  	if err != nil {
    54  		err = autorest.NewErrorWithError(err, "media.OperationStatusesClient", "Get", nil, "Failure preparing request")
    55  		return
    56  	}
    57  
    58  	resp, err := client.GetSender(req)
    59  	if err != nil {
    60  		result.Response = autorest.Response{Response: resp}
    61  		err = autorest.NewErrorWithError(err, "media.OperationStatusesClient", "Get", resp, "Failure sending request")
    62  		return
    63  	}
    64  
    65  	result, err = client.GetResponder(resp)
    66  	if err != nil {
    67  		err = autorest.NewErrorWithError(err, "media.OperationStatusesClient", "Get", resp, "Failure responding to request")
    68  		return
    69  	}
    70  
    71  	return
    72  }
    73  
    74  // GetPreparer prepares the Get request.
    75  func (client OperationStatusesClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string, assetName string, trackName string, operationID string) (*http.Request, error) {
    76  	pathParameters := map[string]interface{}{
    77  		"accountName":       autorest.Encode("path", accountName),
    78  		"assetName":         autorest.Encode("path", assetName),
    79  		"operationId":       autorest.Encode("path", operationID),
    80  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
    81  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
    82  		"trackName":         autorest.Encode("path", trackName),
    83  	}
    84  
    85  	const APIVersion = "2021-11-01"
    86  	queryParameters := map[string]interface{}{
    87  		"api-version": APIVersion,
    88  	}
    89  
    90  	preparer := autorest.CreatePreparer(
    91  		autorest.AsGet(),
    92  		autorest.WithBaseURL(client.BaseURI),
    93  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}/operationStatuses/{operationId}", pathParameters),
    94  		autorest.WithQueryParameters(queryParameters))
    95  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    96  }
    97  
    98  // GetSender sends the Get request. The method will close the
    99  // http.Response Body if it receives an error.
   100  func (client OperationStatusesClient) GetSender(req *http.Request) (*http.Response, error) {
   101  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   102  }
   103  
   104  // GetResponder handles the response to the Get request. The method always
   105  // closes the http.Response Body.
   106  func (client OperationStatusesClient) GetResponder(resp *http.Response) (result AssetTrackOperationStatus, err error) {
   107  	err = autorest.Respond(
   108  		resp,
   109  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   110  		autorest.ByUnmarshallingJSON(&result),
   111  		autorest.ByClosing())
   112  	result.Response = autorest.Response{Response: resp}
   113  	return
   114  }
   115  

View as plain text