...

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

View as plain text