...

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

Documentation: github.com/Azure/azure-sdk-for-go/services/mediaservices/mgmt/2021-05-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  // AssetsClient is the client for the Assets methods of the Media service.
    18  type AssetsClient struct {
    19  	BaseClient
    20  }
    21  
    22  // NewAssetsClient creates an instance of the AssetsClient client.
    23  func NewAssetsClient(subscriptionID string) AssetsClient {
    24  	return NewAssetsClientWithBaseURI(DefaultBaseURI, subscriptionID)
    25  }
    26  
    27  // NewAssetsClientWithBaseURI creates an instance of the AssetsClient 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 NewAssetsClientWithBaseURI(baseURI string, subscriptionID string) AssetsClient {
    30  	return AssetsClient{NewWithBaseURI(baseURI, subscriptionID)}
    31  }
    32  
    33  // CreateOrUpdate creates or updates an Asset in the Media Services account
    34  // Parameters:
    35  // resourceGroupName - the name of the resource group within the Azure subscription.
    36  // accountName - the Media Services account name.
    37  // assetName - the Asset name.
    38  // parameters - the request parameters
    39  func (client AssetsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, assetName string, parameters Asset) (result Asset, err error) {
    40  	if tracing.IsEnabled() {
    41  		ctx = tracing.StartSpan(ctx, fqdn+"/AssetsClient.CreateOrUpdate")
    42  		defer func() {
    43  			sc := -1
    44  			if result.Response.Response != nil {
    45  				sc = result.Response.Response.StatusCode
    46  			}
    47  			tracing.EndSpan(ctx, sc, err)
    48  		}()
    49  	}
    50  	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, accountName, assetName, parameters)
    51  	if err != nil {
    52  		err = autorest.NewErrorWithError(err, "media.AssetsClient", "CreateOrUpdate", nil, "Failure preparing request")
    53  		return
    54  	}
    55  
    56  	resp, err := client.CreateOrUpdateSender(req)
    57  	if err != nil {
    58  		result.Response = autorest.Response{Response: resp}
    59  		err = autorest.NewErrorWithError(err, "media.AssetsClient", "CreateOrUpdate", resp, "Failure sending request")
    60  		return
    61  	}
    62  
    63  	result, err = client.CreateOrUpdateResponder(resp)
    64  	if err != nil {
    65  		err = autorest.NewErrorWithError(err, "media.AssetsClient", "CreateOrUpdate", resp, "Failure responding to request")
    66  		return
    67  	}
    68  
    69  	return
    70  }
    71  
    72  // CreateOrUpdatePreparer prepares the CreateOrUpdate request.
    73  func (client AssetsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, assetName string, parameters Asset) (*http.Request, error) {
    74  	pathParameters := map[string]interface{}{
    75  		"accountName":       autorest.Encode("path", accountName),
    76  		"assetName":         autorest.Encode("path", assetName),
    77  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
    78  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
    79  	}
    80  
    81  	const APIVersion = "2020-05-01"
    82  	queryParameters := map[string]interface{}{
    83  		"api-version": APIVersion,
    84  	}
    85  
    86  	parameters.SystemData = nil
    87  	preparer := autorest.CreatePreparer(
    88  		autorest.AsContentType("application/json; charset=utf-8"),
    89  		autorest.AsPut(),
    90  		autorest.WithBaseURL(client.BaseURI),
    91  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}", pathParameters),
    92  		autorest.WithJSON(parameters),
    93  		autorest.WithQueryParameters(queryParameters))
    94  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    95  }
    96  
    97  // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
    98  // http.Response Body if it receives an error.
    99  func (client AssetsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
   100  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   101  }
   102  
   103  // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
   104  // closes the http.Response Body.
   105  func (client AssetsClient) CreateOrUpdateResponder(resp *http.Response) (result Asset, err error) {
   106  	err = autorest.Respond(
   107  		resp,
   108  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
   109  		autorest.ByUnmarshallingJSON(&result),
   110  		autorest.ByClosing())
   111  	result.Response = autorest.Response{Response: resp}
   112  	return
   113  }
   114  
   115  // Delete deletes an Asset in the Media Services account
   116  // Parameters:
   117  // resourceGroupName - the name of the resource group within the Azure subscription.
   118  // accountName - the Media Services account name.
   119  // assetName - the Asset name.
   120  func (client AssetsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, assetName string) (result autorest.Response, err error) {
   121  	if tracing.IsEnabled() {
   122  		ctx = tracing.StartSpan(ctx, fqdn+"/AssetsClient.Delete")
   123  		defer func() {
   124  			sc := -1
   125  			if result.Response != nil {
   126  				sc = result.Response.StatusCode
   127  			}
   128  			tracing.EndSpan(ctx, sc, err)
   129  		}()
   130  	}
   131  	req, err := client.DeletePreparer(ctx, resourceGroupName, accountName, assetName)
   132  	if err != nil {
   133  		err = autorest.NewErrorWithError(err, "media.AssetsClient", "Delete", nil, "Failure preparing request")
   134  		return
   135  	}
   136  
   137  	resp, err := client.DeleteSender(req)
   138  	if err != nil {
   139  		result.Response = resp
   140  		err = autorest.NewErrorWithError(err, "media.AssetsClient", "Delete", resp, "Failure sending request")
   141  		return
   142  	}
   143  
   144  	result, err = client.DeleteResponder(resp)
   145  	if err != nil {
   146  		err = autorest.NewErrorWithError(err, "media.AssetsClient", "Delete", resp, "Failure responding to request")
   147  		return
   148  	}
   149  
   150  	return
   151  }
   152  
   153  // DeletePreparer prepares the Delete request.
   154  func (client AssetsClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string, assetName string) (*http.Request, error) {
   155  	pathParameters := map[string]interface{}{
   156  		"accountName":       autorest.Encode("path", accountName),
   157  		"assetName":         autorest.Encode("path", assetName),
   158  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   159  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   160  	}
   161  
   162  	const APIVersion = "2020-05-01"
   163  	queryParameters := map[string]interface{}{
   164  		"api-version": APIVersion,
   165  	}
   166  
   167  	preparer := autorest.CreatePreparer(
   168  		autorest.AsDelete(),
   169  		autorest.WithBaseURL(client.BaseURI),
   170  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}", pathParameters),
   171  		autorest.WithQueryParameters(queryParameters))
   172  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   173  }
   174  
   175  // DeleteSender sends the Delete request. The method will close the
   176  // http.Response Body if it receives an error.
   177  func (client AssetsClient) DeleteSender(req *http.Request) (*http.Response, error) {
   178  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   179  }
   180  
   181  // DeleteResponder handles the response to the Delete request. The method always
   182  // closes the http.Response Body.
   183  func (client AssetsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
   184  	err = autorest.Respond(
   185  		resp,
   186  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
   187  		autorest.ByClosing())
   188  	result.Response = resp
   189  	return
   190  }
   191  
   192  // Get get the details of an Asset in the Media Services account
   193  // Parameters:
   194  // resourceGroupName - the name of the resource group within the Azure subscription.
   195  // accountName - the Media Services account name.
   196  // assetName - the Asset name.
   197  func (client AssetsClient) Get(ctx context.Context, resourceGroupName string, accountName string, assetName string) (result Asset, err error) {
   198  	if tracing.IsEnabled() {
   199  		ctx = tracing.StartSpan(ctx, fqdn+"/AssetsClient.Get")
   200  		defer func() {
   201  			sc := -1
   202  			if result.Response.Response != nil {
   203  				sc = result.Response.Response.StatusCode
   204  			}
   205  			tracing.EndSpan(ctx, sc, err)
   206  		}()
   207  	}
   208  	req, err := client.GetPreparer(ctx, resourceGroupName, accountName, assetName)
   209  	if err != nil {
   210  		err = autorest.NewErrorWithError(err, "media.AssetsClient", "Get", nil, "Failure preparing request")
   211  		return
   212  	}
   213  
   214  	resp, err := client.GetSender(req)
   215  	if err != nil {
   216  		result.Response = autorest.Response{Response: resp}
   217  		err = autorest.NewErrorWithError(err, "media.AssetsClient", "Get", resp, "Failure sending request")
   218  		return
   219  	}
   220  
   221  	result, err = client.GetResponder(resp)
   222  	if err != nil {
   223  		err = autorest.NewErrorWithError(err, "media.AssetsClient", "Get", resp, "Failure responding to request")
   224  		return
   225  	}
   226  
   227  	return
   228  }
   229  
   230  // GetPreparer prepares the Get request.
   231  func (client AssetsClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string, assetName string) (*http.Request, error) {
   232  	pathParameters := map[string]interface{}{
   233  		"accountName":       autorest.Encode("path", accountName),
   234  		"assetName":         autorest.Encode("path", assetName),
   235  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   236  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   237  	}
   238  
   239  	const APIVersion = "2020-05-01"
   240  	queryParameters := map[string]interface{}{
   241  		"api-version": APIVersion,
   242  	}
   243  
   244  	preparer := autorest.CreatePreparer(
   245  		autorest.AsGet(),
   246  		autorest.WithBaseURL(client.BaseURI),
   247  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}", pathParameters),
   248  		autorest.WithQueryParameters(queryParameters))
   249  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   250  }
   251  
   252  // GetSender sends the Get request. The method will close the
   253  // http.Response Body if it receives an error.
   254  func (client AssetsClient) GetSender(req *http.Request) (*http.Response, error) {
   255  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   256  }
   257  
   258  // GetResponder handles the response to the Get request. The method always
   259  // closes the http.Response Body.
   260  func (client AssetsClient) GetResponder(resp *http.Response) (result Asset, err error) {
   261  	err = autorest.Respond(
   262  		resp,
   263  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNotFound),
   264  		autorest.ByUnmarshallingJSON(&result),
   265  		autorest.ByClosing())
   266  	result.Response = autorest.Response{Response: resp}
   267  	return
   268  }
   269  
   270  // GetEncryptionKey gets the Asset storage encryption keys used to decrypt content created by version 2 of the Media
   271  // Services API
   272  // Parameters:
   273  // resourceGroupName - the name of the resource group within the Azure subscription.
   274  // accountName - the Media Services account name.
   275  // assetName - the Asset name.
   276  func (client AssetsClient) GetEncryptionKey(ctx context.Context, resourceGroupName string, accountName string, assetName string) (result StorageEncryptedAssetDecryptionData, err error) {
   277  	if tracing.IsEnabled() {
   278  		ctx = tracing.StartSpan(ctx, fqdn+"/AssetsClient.GetEncryptionKey")
   279  		defer func() {
   280  			sc := -1
   281  			if result.Response.Response != nil {
   282  				sc = result.Response.Response.StatusCode
   283  			}
   284  			tracing.EndSpan(ctx, sc, err)
   285  		}()
   286  	}
   287  	req, err := client.GetEncryptionKeyPreparer(ctx, resourceGroupName, accountName, assetName)
   288  	if err != nil {
   289  		err = autorest.NewErrorWithError(err, "media.AssetsClient", "GetEncryptionKey", nil, "Failure preparing request")
   290  		return
   291  	}
   292  
   293  	resp, err := client.GetEncryptionKeySender(req)
   294  	if err != nil {
   295  		result.Response = autorest.Response{Response: resp}
   296  		err = autorest.NewErrorWithError(err, "media.AssetsClient", "GetEncryptionKey", resp, "Failure sending request")
   297  		return
   298  	}
   299  
   300  	result, err = client.GetEncryptionKeyResponder(resp)
   301  	if err != nil {
   302  		err = autorest.NewErrorWithError(err, "media.AssetsClient", "GetEncryptionKey", resp, "Failure responding to request")
   303  		return
   304  	}
   305  
   306  	return
   307  }
   308  
   309  // GetEncryptionKeyPreparer prepares the GetEncryptionKey request.
   310  func (client AssetsClient) GetEncryptionKeyPreparer(ctx context.Context, resourceGroupName string, accountName string, assetName string) (*http.Request, error) {
   311  	pathParameters := map[string]interface{}{
   312  		"accountName":       autorest.Encode("path", accountName),
   313  		"assetName":         autorest.Encode("path", assetName),
   314  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   315  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   316  	}
   317  
   318  	const APIVersion = "2020-05-01"
   319  	queryParameters := map[string]interface{}{
   320  		"api-version": APIVersion,
   321  	}
   322  
   323  	preparer := autorest.CreatePreparer(
   324  		autorest.AsPost(),
   325  		autorest.WithBaseURL(client.BaseURI),
   326  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/getEncryptionKey", pathParameters),
   327  		autorest.WithQueryParameters(queryParameters))
   328  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   329  }
   330  
   331  // GetEncryptionKeySender sends the GetEncryptionKey request. The method will close the
   332  // http.Response Body if it receives an error.
   333  func (client AssetsClient) GetEncryptionKeySender(req *http.Request) (*http.Response, error) {
   334  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   335  }
   336  
   337  // GetEncryptionKeyResponder handles the response to the GetEncryptionKey request. The method always
   338  // closes the http.Response Body.
   339  func (client AssetsClient) GetEncryptionKeyResponder(resp *http.Response) (result StorageEncryptedAssetDecryptionData, err error) {
   340  	err = autorest.Respond(
   341  		resp,
   342  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   343  		autorest.ByUnmarshallingJSON(&result),
   344  		autorest.ByClosing())
   345  	result.Response = autorest.Response{Response: resp}
   346  	return
   347  }
   348  
   349  // List list Assets in the Media Services account with optional filtering and ordering
   350  // Parameters:
   351  // resourceGroupName - the name of the resource group within the Azure subscription.
   352  // accountName - the Media Services account name.
   353  // filter - restricts the set of items returned.
   354  // top - specifies a non-negative integer n that limits the number of items returned from a collection. The
   355  // service returns the number of available items up to but not greater than the specified value n.
   356  // orderby - specifies the key by which the result collection should be ordered.
   357  func (client AssetsClient) List(ctx context.Context, resourceGroupName string, accountName string, filter string, top *int32, orderby string) (result AssetCollectionPage, err error) {
   358  	if tracing.IsEnabled() {
   359  		ctx = tracing.StartSpan(ctx, fqdn+"/AssetsClient.List")
   360  		defer func() {
   361  			sc := -1
   362  			if result.ac.Response.Response != nil {
   363  				sc = result.ac.Response.Response.StatusCode
   364  			}
   365  			tracing.EndSpan(ctx, sc, err)
   366  		}()
   367  	}
   368  	result.fn = client.listNextResults
   369  	req, err := client.ListPreparer(ctx, resourceGroupName, accountName, filter, top, orderby)
   370  	if err != nil {
   371  		err = autorest.NewErrorWithError(err, "media.AssetsClient", "List", nil, "Failure preparing request")
   372  		return
   373  	}
   374  
   375  	resp, err := client.ListSender(req)
   376  	if err != nil {
   377  		result.ac.Response = autorest.Response{Response: resp}
   378  		err = autorest.NewErrorWithError(err, "media.AssetsClient", "List", resp, "Failure sending request")
   379  		return
   380  	}
   381  
   382  	result.ac, err = client.ListResponder(resp)
   383  	if err != nil {
   384  		err = autorest.NewErrorWithError(err, "media.AssetsClient", "List", resp, "Failure responding to request")
   385  		return
   386  	}
   387  	if result.ac.hasNextLink() && result.ac.IsEmpty() {
   388  		err = result.NextWithContext(ctx)
   389  		return
   390  	}
   391  
   392  	return
   393  }
   394  
   395  // ListPreparer prepares the List request.
   396  func (client AssetsClient) ListPreparer(ctx context.Context, resourceGroupName string, accountName string, filter string, top *int32, orderby string) (*http.Request, error) {
   397  	pathParameters := map[string]interface{}{
   398  		"accountName":       autorest.Encode("path", accountName),
   399  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   400  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   401  	}
   402  
   403  	const APIVersion = "2020-05-01"
   404  	queryParameters := map[string]interface{}{
   405  		"api-version": APIVersion,
   406  	}
   407  	if len(filter) > 0 {
   408  		queryParameters["$filter"] = autorest.Encode("query", filter)
   409  	}
   410  	if top != nil {
   411  		queryParameters["$top"] = autorest.Encode("query", *top)
   412  	}
   413  	if len(orderby) > 0 {
   414  		queryParameters["$orderby"] = autorest.Encode("query", orderby)
   415  	}
   416  
   417  	preparer := autorest.CreatePreparer(
   418  		autorest.AsGet(),
   419  		autorest.WithBaseURL(client.BaseURI),
   420  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets", pathParameters),
   421  		autorest.WithQueryParameters(queryParameters))
   422  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   423  }
   424  
   425  // ListSender sends the List request. The method will close the
   426  // http.Response Body if it receives an error.
   427  func (client AssetsClient) ListSender(req *http.Request) (*http.Response, error) {
   428  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   429  }
   430  
   431  // ListResponder handles the response to the List request. The method always
   432  // closes the http.Response Body.
   433  func (client AssetsClient) ListResponder(resp *http.Response) (result AssetCollection, err error) {
   434  	err = autorest.Respond(
   435  		resp,
   436  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   437  		autorest.ByUnmarshallingJSON(&result),
   438  		autorest.ByClosing())
   439  	result.Response = autorest.Response{Response: resp}
   440  	return
   441  }
   442  
   443  // listNextResults retrieves the next set of results, if any.
   444  func (client AssetsClient) listNextResults(ctx context.Context, lastResults AssetCollection) (result AssetCollection, err error) {
   445  	req, err := lastResults.assetCollectionPreparer(ctx)
   446  	if err != nil {
   447  		return result, autorest.NewErrorWithError(err, "media.AssetsClient", "listNextResults", nil, "Failure preparing next results request")
   448  	}
   449  	if req == nil {
   450  		return
   451  	}
   452  	resp, err := client.ListSender(req)
   453  	if err != nil {
   454  		result.Response = autorest.Response{Response: resp}
   455  		return result, autorest.NewErrorWithError(err, "media.AssetsClient", "listNextResults", resp, "Failure sending next results request")
   456  	}
   457  	result, err = client.ListResponder(resp)
   458  	if err != nil {
   459  		err = autorest.NewErrorWithError(err, "media.AssetsClient", "listNextResults", resp, "Failure responding to next results request")
   460  	}
   461  	return
   462  }
   463  
   464  // ListComplete enumerates all values, automatically crossing page boundaries as required.
   465  func (client AssetsClient) ListComplete(ctx context.Context, resourceGroupName string, accountName string, filter string, top *int32, orderby string) (result AssetCollectionIterator, err error) {
   466  	if tracing.IsEnabled() {
   467  		ctx = tracing.StartSpan(ctx, fqdn+"/AssetsClient.List")
   468  		defer func() {
   469  			sc := -1
   470  			if result.Response().Response.Response != nil {
   471  				sc = result.page.Response().Response.Response.StatusCode
   472  			}
   473  			tracing.EndSpan(ctx, sc, err)
   474  		}()
   475  	}
   476  	result.page, err = client.List(ctx, resourceGroupName, accountName, filter, top, orderby)
   477  	return
   478  }
   479  
   480  // ListContainerSas lists storage container URLs with shared access signatures (SAS) for uploading and downloading
   481  // Asset content. The signatures are derived from the storage account keys.
   482  // Parameters:
   483  // resourceGroupName - the name of the resource group within the Azure subscription.
   484  // accountName - the Media Services account name.
   485  // assetName - the Asset name.
   486  // parameters - the request parameters
   487  func (client AssetsClient) ListContainerSas(ctx context.Context, resourceGroupName string, accountName string, assetName string, parameters ListContainerSasInput) (result AssetContainerSas, err error) {
   488  	if tracing.IsEnabled() {
   489  		ctx = tracing.StartSpan(ctx, fqdn+"/AssetsClient.ListContainerSas")
   490  		defer func() {
   491  			sc := -1
   492  			if result.Response.Response != nil {
   493  				sc = result.Response.Response.StatusCode
   494  			}
   495  			tracing.EndSpan(ctx, sc, err)
   496  		}()
   497  	}
   498  	req, err := client.ListContainerSasPreparer(ctx, resourceGroupName, accountName, assetName, parameters)
   499  	if err != nil {
   500  		err = autorest.NewErrorWithError(err, "media.AssetsClient", "ListContainerSas", nil, "Failure preparing request")
   501  		return
   502  	}
   503  
   504  	resp, err := client.ListContainerSasSender(req)
   505  	if err != nil {
   506  		result.Response = autorest.Response{Response: resp}
   507  		err = autorest.NewErrorWithError(err, "media.AssetsClient", "ListContainerSas", resp, "Failure sending request")
   508  		return
   509  	}
   510  
   511  	result, err = client.ListContainerSasResponder(resp)
   512  	if err != nil {
   513  		err = autorest.NewErrorWithError(err, "media.AssetsClient", "ListContainerSas", resp, "Failure responding to request")
   514  		return
   515  	}
   516  
   517  	return
   518  }
   519  
   520  // ListContainerSasPreparer prepares the ListContainerSas request.
   521  func (client AssetsClient) ListContainerSasPreparer(ctx context.Context, resourceGroupName string, accountName string, assetName string, parameters ListContainerSasInput) (*http.Request, error) {
   522  	pathParameters := map[string]interface{}{
   523  		"accountName":       autorest.Encode("path", accountName),
   524  		"assetName":         autorest.Encode("path", assetName),
   525  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   526  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   527  	}
   528  
   529  	const APIVersion = "2020-05-01"
   530  	queryParameters := map[string]interface{}{
   531  		"api-version": APIVersion,
   532  	}
   533  
   534  	preparer := autorest.CreatePreparer(
   535  		autorest.AsContentType("application/json; charset=utf-8"),
   536  		autorest.AsPost(),
   537  		autorest.WithBaseURL(client.BaseURI),
   538  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/listContainerSas", pathParameters),
   539  		autorest.WithJSON(parameters),
   540  		autorest.WithQueryParameters(queryParameters))
   541  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   542  }
   543  
   544  // ListContainerSasSender sends the ListContainerSas request. The method will close the
   545  // http.Response Body if it receives an error.
   546  func (client AssetsClient) ListContainerSasSender(req *http.Request) (*http.Response, error) {
   547  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   548  }
   549  
   550  // ListContainerSasResponder handles the response to the ListContainerSas request. The method always
   551  // closes the http.Response Body.
   552  func (client AssetsClient) ListContainerSasResponder(resp *http.Response) (result AssetContainerSas, err error) {
   553  	err = autorest.Respond(
   554  		resp,
   555  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   556  		autorest.ByUnmarshallingJSON(&result),
   557  		autorest.ByClosing())
   558  	result.Response = autorest.Response{Response: resp}
   559  	return
   560  }
   561  
   562  // ListStreamingLocators lists Streaming Locators which are associated with this asset.
   563  // Parameters:
   564  // resourceGroupName - the name of the resource group within the Azure subscription.
   565  // accountName - the Media Services account name.
   566  // assetName - the Asset name.
   567  func (client AssetsClient) ListStreamingLocators(ctx context.Context, resourceGroupName string, accountName string, assetName string) (result ListStreamingLocatorsResponse, err error) {
   568  	if tracing.IsEnabled() {
   569  		ctx = tracing.StartSpan(ctx, fqdn+"/AssetsClient.ListStreamingLocators")
   570  		defer func() {
   571  			sc := -1
   572  			if result.Response.Response != nil {
   573  				sc = result.Response.Response.StatusCode
   574  			}
   575  			tracing.EndSpan(ctx, sc, err)
   576  		}()
   577  	}
   578  	req, err := client.ListStreamingLocatorsPreparer(ctx, resourceGroupName, accountName, assetName)
   579  	if err != nil {
   580  		err = autorest.NewErrorWithError(err, "media.AssetsClient", "ListStreamingLocators", nil, "Failure preparing request")
   581  		return
   582  	}
   583  
   584  	resp, err := client.ListStreamingLocatorsSender(req)
   585  	if err != nil {
   586  		result.Response = autorest.Response{Response: resp}
   587  		err = autorest.NewErrorWithError(err, "media.AssetsClient", "ListStreamingLocators", resp, "Failure sending request")
   588  		return
   589  	}
   590  
   591  	result, err = client.ListStreamingLocatorsResponder(resp)
   592  	if err != nil {
   593  		err = autorest.NewErrorWithError(err, "media.AssetsClient", "ListStreamingLocators", resp, "Failure responding to request")
   594  		return
   595  	}
   596  
   597  	return
   598  }
   599  
   600  // ListStreamingLocatorsPreparer prepares the ListStreamingLocators request.
   601  func (client AssetsClient) ListStreamingLocatorsPreparer(ctx context.Context, resourceGroupName string, accountName string, assetName string) (*http.Request, error) {
   602  	pathParameters := map[string]interface{}{
   603  		"accountName":       autorest.Encode("path", accountName),
   604  		"assetName":         autorest.Encode("path", assetName),
   605  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   606  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   607  	}
   608  
   609  	const APIVersion = "2020-05-01"
   610  	queryParameters := map[string]interface{}{
   611  		"api-version": APIVersion,
   612  	}
   613  
   614  	preparer := autorest.CreatePreparer(
   615  		autorest.AsPost(),
   616  		autorest.WithBaseURL(client.BaseURI),
   617  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/listStreamingLocators", pathParameters),
   618  		autorest.WithQueryParameters(queryParameters))
   619  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   620  }
   621  
   622  // ListStreamingLocatorsSender sends the ListStreamingLocators request. The method will close the
   623  // http.Response Body if it receives an error.
   624  func (client AssetsClient) ListStreamingLocatorsSender(req *http.Request) (*http.Response, error) {
   625  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   626  }
   627  
   628  // ListStreamingLocatorsResponder handles the response to the ListStreamingLocators request. The method always
   629  // closes the http.Response Body.
   630  func (client AssetsClient) ListStreamingLocatorsResponder(resp *http.Response) (result ListStreamingLocatorsResponse, err error) {
   631  	err = autorest.Respond(
   632  		resp,
   633  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   634  		autorest.ByUnmarshallingJSON(&result),
   635  		autorest.ByClosing())
   636  	result.Response = autorest.Response{Response: resp}
   637  	return
   638  }
   639  
   640  // Update updates an existing Asset in the Media Services account
   641  // Parameters:
   642  // resourceGroupName - the name of the resource group within the Azure subscription.
   643  // accountName - the Media Services account name.
   644  // assetName - the Asset name.
   645  // parameters - the request parameters
   646  func (client AssetsClient) Update(ctx context.Context, resourceGroupName string, accountName string, assetName string, parameters Asset) (result Asset, err error) {
   647  	if tracing.IsEnabled() {
   648  		ctx = tracing.StartSpan(ctx, fqdn+"/AssetsClient.Update")
   649  		defer func() {
   650  			sc := -1
   651  			if result.Response.Response != nil {
   652  				sc = result.Response.Response.StatusCode
   653  			}
   654  			tracing.EndSpan(ctx, sc, err)
   655  		}()
   656  	}
   657  	req, err := client.UpdatePreparer(ctx, resourceGroupName, accountName, assetName, parameters)
   658  	if err != nil {
   659  		err = autorest.NewErrorWithError(err, "media.AssetsClient", "Update", nil, "Failure preparing request")
   660  		return
   661  	}
   662  
   663  	resp, err := client.UpdateSender(req)
   664  	if err != nil {
   665  		result.Response = autorest.Response{Response: resp}
   666  		err = autorest.NewErrorWithError(err, "media.AssetsClient", "Update", resp, "Failure sending request")
   667  		return
   668  	}
   669  
   670  	result, err = client.UpdateResponder(resp)
   671  	if err != nil {
   672  		err = autorest.NewErrorWithError(err, "media.AssetsClient", "Update", resp, "Failure responding to request")
   673  		return
   674  	}
   675  
   676  	return
   677  }
   678  
   679  // UpdatePreparer prepares the Update request.
   680  func (client AssetsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, assetName string, parameters Asset) (*http.Request, error) {
   681  	pathParameters := map[string]interface{}{
   682  		"accountName":       autorest.Encode("path", accountName),
   683  		"assetName":         autorest.Encode("path", assetName),
   684  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   685  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   686  	}
   687  
   688  	const APIVersion = "2020-05-01"
   689  	queryParameters := map[string]interface{}{
   690  		"api-version": APIVersion,
   691  	}
   692  
   693  	parameters.SystemData = nil
   694  	preparer := autorest.CreatePreparer(
   695  		autorest.AsContentType("application/json; charset=utf-8"),
   696  		autorest.AsPatch(),
   697  		autorest.WithBaseURL(client.BaseURI),
   698  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}", pathParameters),
   699  		autorest.WithJSON(parameters),
   700  		autorest.WithQueryParameters(queryParameters))
   701  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   702  }
   703  
   704  // UpdateSender sends the Update request. The method will close the
   705  // http.Response Body if it receives an error.
   706  func (client AssetsClient) UpdateSender(req *http.Request) (*http.Response, error) {
   707  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   708  }
   709  
   710  // UpdateResponder handles the response to the Update request. The method always
   711  // closes the http.Response Body.
   712  func (client AssetsClient) UpdateResponder(resp *http.Response) (result Asset, err error) {
   713  	err = autorest.Respond(
   714  		resp,
   715  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   716  		autorest.ByUnmarshallingJSON(&result),
   717  		autorest.ByClosing())
   718  	result.Response = autorest.Response{Response: resp}
   719  	return
   720  }
   721  

View as plain text