...

Source file src/github.com/Azure/azure-sdk-for-go/services/preview/mediaservices/mgmt/2019-05-01-preview/media/jobs.go

Documentation: github.com/Azure/azure-sdk-for-go/services/preview/mediaservices/mgmt/2019-05-01-preview/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/autorest/validation"
    14  	"github.com/Azure/go-autorest/tracing"
    15  	"net/http"
    16  )
    17  
    18  // JobsClient is the client for the Jobs methods of the Media service.
    19  type JobsClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewJobsClient creates an instance of the JobsClient client.
    24  func NewJobsClient(subscriptionID string) JobsClient {
    25  	return NewJobsClientWithBaseURI(DefaultBaseURI, subscriptionID)
    26  }
    27  
    28  // NewJobsClientWithBaseURI creates an instance of the JobsClient client using a custom endpoint.  Use this when
    29  // interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
    30  func NewJobsClientWithBaseURI(baseURI string, subscriptionID string) JobsClient {
    31  	return JobsClient{NewWithBaseURI(baseURI, subscriptionID)}
    32  }
    33  
    34  // CancelJob cancel a Job.
    35  // Parameters:
    36  // resourceGroupName - the name of the resource group within the Azure subscription.
    37  // accountName - the Media Services account name.
    38  // transformName - the Transform name.
    39  // jobName - the Job name.
    40  func (client JobsClient) CancelJob(ctx context.Context, resourceGroupName string, accountName string, transformName string, jobName string) (result autorest.Response, err error) {
    41  	if tracing.IsEnabled() {
    42  		ctx = tracing.StartSpan(ctx, fqdn+"/JobsClient.CancelJob")
    43  		defer func() {
    44  			sc := -1
    45  			if result.Response != nil {
    46  				sc = result.Response.StatusCode
    47  			}
    48  			tracing.EndSpan(ctx, sc, err)
    49  		}()
    50  	}
    51  	req, err := client.CancelJobPreparer(ctx, resourceGroupName, accountName, transformName, jobName)
    52  	if err != nil {
    53  		err = autorest.NewErrorWithError(err, "media.JobsClient", "CancelJob", nil, "Failure preparing request")
    54  		return
    55  	}
    56  
    57  	resp, err := client.CancelJobSender(req)
    58  	if err != nil {
    59  		result.Response = resp
    60  		err = autorest.NewErrorWithError(err, "media.JobsClient", "CancelJob", resp, "Failure sending request")
    61  		return
    62  	}
    63  
    64  	result, err = client.CancelJobResponder(resp)
    65  	if err != nil {
    66  		err = autorest.NewErrorWithError(err, "media.JobsClient", "CancelJob", resp, "Failure responding to request")
    67  		return
    68  	}
    69  
    70  	return
    71  }
    72  
    73  // CancelJobPreparer prepares the CancelJob request.
    74  func (client JobsClient) CancelJobPreparer(ctx context.Context, resourceGroupName string, accountName string, transformName string, jobName string) (*http.Request, error) {
    75  	pathParameters := map[string]interface{}{
    76  		"accountName":       autorest.Encode("path", accountName),
    77  		"jobName":           autorest.Encode("path", jobName),
    78  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
    79  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
    80  		"transformName":     autorest.Encode("path", transformName),
    81  	}
    82  
    83  	const APIVersion = "2018-07-01"
    84  	queryParameters := map[string]interface{}{
    85  		"api-version": APIVersion,
    86  	}
    87  
    88  	preparer := autorest.CreatePreparer(
    89  		autorest.AsPost(),
    90  		autorest.WithBaseURL(client.BaseURI),
    91  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}/jobs/{jobName}/cancelJob", pathParameters),
    92  		autorest.WithQueryParameters(queryParameters))
    93  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    94  }
    95  
    96  // CancelJobSender sends the CancelJob request. The method will close the
    97  // http.Response Body if it receives an error.
    98  func (client JobsClient) CancelJobSender(req *http.Request) (*http.Response, error) {
    99  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   100  }
   101  
   102  // CancelJobResponder handles the response to the CancelJob request. The method always
   103  // closes the http.Response Body.
   104  func (client JobsClient) CancelJobResponder(resp *http.Response) (result autorest.Response, err error) {
   105  	err = autorest.Respond(
   106  		resp,
   107  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   108  		autorest.ByClosing())
   109  	result.Response = resp
   110  	return
   111  }
   112  
   113  // Create creates a Job.
   114  // Parameters:
   115  // resourceGroupName - the name of the resource group within the Azure subscription.
   116  // accountName - the Media Services account name.
   117  // transformName - the Transform name.
   118  // jobName - the Job name.
   119  // parameters - the request parameters
   120  func (client JobsClient) Create(ctx context.Context, resourceGroupName string, accountName string, transformName string, jobName string, parameters Job) (result Job, err error) {
   121  	if tracing.IsEnabled() {
   122  		ctx = tracing.StartSpan(ctx, fqdn+"/JobsClient.Create")
   123  		defer func() {
   124  			sc := -1
   125  			if result.Response.Response != nil {
   126  				sc = result.Response.Response.StatusCode
   127  			}
   128  			tracing.EndSpan(ctx, sc, err)
   129  		}()
   130  	}
   131  	if err := validation.Validate([]validation.Validation{
   132  		{TargetValue: parameters,
   133  			Constraints: []validation.Constraint{{Target: "parameters.JobProperties", Name: validation.Null, Rule: false,
   134  				Chain: []validation.Constraint{{Target: "parameters.JobProperties.Outputs", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil {
   135  		return result, validation.NewError("media.JobsClient", "Create", err.Error())
   136  	}
   137  
   138  	req, err := client.CreatePreparer(ctx, resourceGroupName, accountName, transformName, jobName, parameters)
   139  	if err != nil {
   140  		err = autorest.NewErrorWithError(err, "media.JobsClient", "Create", nil, "Failure preparing request")
   141  		return
   142  	}
   143  
   144  	resp, err := client.CreateSender(req)
   145  	if err != nil {
   146  		result.Response = autorest.Response{Response: resp}
   147  		err = autorest.NewErrorWithError(err, "media.JobsClient", "Create", resp, "Failure sending request")
   148  		return
   149  	}
   150  
   151  	result, err = client.CreateResponder(resp)
   152  	if err != nil {
   153  		err = autorest.NewErrorWithError(err, "media.JobsClient", "Create", resp, "Failure responding to request")
   154  		return
   155  	}
   156  
   157  	return
   158  }
   159  
   160  // CreatePreparer prepares the Create request.
   161  func (client JobsClient) CreatePreparer(ctx context.Context, resourceGroupName string, accountName string, transformName string, jobName string, parameters Job) (*http.Request, error) {
   162  	pathParameters := map[string]interface{}{
   163  		"accountName":       autorest.Encode("path", accountName),
   164  		"jobName":           autorest.Encode("path", jobName),
   165  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   166  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   167  		"transformName":     autorest.Encode("path", transformName),
   168  	}
   169  
   170  	const APIVersion = "2018-07-01"
   171  	queryParameters := map[string]interface{}{
   172  		"api-version": APIVersion,
   173  	}
   174  
   175  	preparer := autorest.CreatePreparer(
   176  		autorest.AsContentType("application/json; charset=utf-8"),
   177  		autorest.AsPut(),
   178  		autorest.WithBaseURL(client.BaseURI),
   179  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}/jobs/{jobName}", pathParameters),
   180  		autorest.WithJSON(parameters),
   181  		autorest.WithQueryParameters(queryParameters))
   182  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   183  }
   184  
   185  // CreateSender sends the Create request. The method will close the
   186  // http.Response Body if it receives an error.
   187  func (client JobsClient) CreateSender(req *http.Request) (*http.Response, error) {
   188  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   189  }
   190  
   191  // CreateResponder handles the response to the Create request. The method always
   192  // closes the http.Response Body.
   193  func (client JobsClient) CreateResponder(resp *http.Response) (result Job, err error) {
   194  	err = autorest.Respond(
   195  		resp,
   196  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
   197  		autorest.ByUnmarshallingJSON(&result),
   198  		autorest.ByClosing())
   199  	result.Response = autorest.Response{Response: resp}
   200  	return
   201  }
   202  
   203  // Delete deletes a Job.
   204  // Parameters:
   205  // resourceGroupName - the name of the resource group within the Azure subscription.
   206  // accountName - the Media Services account name.
   207  // transformName - the Transform name.
   208  // jobName - the Job name.
   209  func (client JobsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, transformName string, jobName string) (result autorest.Response, err error) {
   210  	if tracing.IsEnabled() {
   211  		ctx = tracing.StartSpan(ctx, fqdn+"/JobsClient.Delete")
   212  		defer func() {
   213  			sc := -1
   214  			if result.Response != nil {
   215  				sc = result.Response.StatusCode
   216  			}
   217  			tracing.EndSpan(ctx, sc, err)
   218  		}()
   219  	}
   220  	req, err := client.DeletePreparer(ctx, resourceGroupName, accountName, transformName, jobName)
   221  	if err != nil {
   222  		err = autorest.NewErrorWithError(err, "media.JobsClient", "Delete", nil, "Failure preparing request")
   223  		return
   224  	}
   225  
   226  	resp, err := client.DeleteSender(req)
   227  	if err != nil {
   228  		result.Response = resp
   229  		err = autorest.NewErrorWithError(err, "media.JobsClient", "Delete", resp, "Failure sending request")
   230  		return
   231  	}
   232  
   233  	result, err = client.DeleteResponder(resp)
   234  	if err != nil {
   235  		err = autorest.NewErrorWithError(err, "media.JobsClient", "Delete", resp, "Failure responding to request")
   236  		return
   237  	}
   238  
   239  	return
   240  }
   241  
   242  // DeletePreparer prepares the Delete request.
   243  func (client JobsClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string, transformName string, jobName string) (*http.Request, error) {
   244  	pathParameters := map[string]interface{}{
   245  		"accountName":       autorest.Encode("path", accountName),
   246  		"jobName":           autorest.Encode("path", jobName),
   247  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   248  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   249  		"transformName":     autorest.Encode("path", transformName),
   250  	}
   251  
   252  	const APIVersion = "2018-07-01"
   253  	queryParameters := map[string]interface{}{
   254  		"api-version": APIVersion,
   255  	}
   256  
   257  	preparer := autorest.CreatePreparer(
   258  		autorest.AsDelete(),
   259  		autorest.WithBaseURL(client.BaseURI),
   260  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}/jobs/{jobName}", pathParameters),
   261  		autorest.WithQueryParameters(queryParameters))
   262  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   263  }
   264  
   265  // DeleteSender sends the Delete request. The method will close the
   266  // http.Response Body if it receives an error.
   267  func (client JobsClient) DeleteSender(req *http.Request) (*http.Response, error) {
   268  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   269  }
   270  
   271  // DeleteResponder handles the response to the Delete request. The method always
   272  // closes the http.Response Body.
   273  func (client JobsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
   274  	err = autorest.Respond(
   275  		resp,
   276  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
   277  		autorest.ByClosing())
   278  	result.Response = resp
   279  	return
   280  }
   281  
   282  // Get gets a Job.
   283  // Parameters:
   284  // resourceGroupName - the name of the resource group within the Azure subscription.
   285  // accountName - the Media Services account name.
   286  // transformName - the Transform name.
   287  // jobName - the Job name.
   288  func (client JobsClient) Get(ctx context.Context, resourceGroupName string, accountName string, transformName string, jobName string) (result Job, err error) {
   289  	if tracing.IsEnabled() {
   290  		ctx = tracing.StartSpan(ctx, fqdn+"/JobsClient.Get")
   291  		defer func() {
   292  			sc := -1
   293  			if result.Response.Response != nil {
   294  				sc = result.Response.Response.StatusCode
   295  			}
   296  			tracing.EndSpan(ctx, sc, err)
   297  		}()
   298  	}
   299  	req, err := client.GetPreparer(ctx, resourceGroupName, accountName, transformName, jobName)
   300  	if err != nil {
   301  		err = autorest.NewErrorWithError(err, "media.JobsClient", "Get", nil, "Failure preparing request")
   302  		return
   303  	}
   304  
   305  	resp, err := client.GetSender(req)
   306  	if err != nil {
   307  		result.Response = autorest.Response{Response: resp}
   308  		err = autorest.NewErrorWithError(err, "media.JobsClient", "Get", resp, "Failure sending request")
   309  		return
   310  	}
   311  
   312  	result, err = client.GetResponder(resp)
   313  	if err != nil {
   314  		err = autorest.NewErrorWithError(err, "media.JobsClient", "Get", resp, "Failure responding to request")
   315  		return
   316  	}
   317  
   318  	return
   319  }
   320  
   321  // GetPreparer prepares the Get request.
   322  func (client JobsClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string, transformName string, jobName string) (*http.Request, error) {
   323  	pathParameters := map[string]interface{}{
   324  		"accountName":       autorest.Encode("path", accountName),
   325  		"jobName":           autorest.Encode("path", jobName),
   326  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   327  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   328  		"transformName":     autorest.Encode("path", transformName),
   329  	}
   330  
   331  	const APIVersion = "2018-07-01"
   332  	queryParameters := map[string]interface{}{
   333  		"api-version": APIVersion,
   334  	}
   335  
   336  	preparer := autorest.CreatePreparer(
   337  		autorest.AsGet(),
   338  		autorest.WithBaseURL(client.BaseURI),
   339  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}/jobs/{jobName}", pathParameters),
   340  		autorest.WithQueryParameters(queryParameters))
   341  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   342  }
   343  
   344  // GetSender sends the Get request. The method will close the
   345  // http.Response Body if it receives an error.
   346  func (client JobsClient) GetSender(req *http.Request) (*http.Response, error) {
   347  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   348  }
   349  
   350  // GetResponder handles the response to the Get request. The method always
   351  // closes the http.Response Body.
   352  func (client JobsClient) GetResponder(resp *http.Response) (result Job, err error) {
   353  	err = autorest.Respond(
   354  		resp,
   355  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNotFound),
   356  		autorest.ByUnmarshallingJSON(&result),
   357  		autorest.ByClosing())
   358  	result.Response = autorest.Response{Response: resp}
   359  	return
   360  }
   361  
   362  // List lists all of the Jobs for the Transform.
   363  // Parameters:
   364  // resourceGroupName - the name of the resource group within the Azure subscription.
   365  // accountName - the Media Services account name.
   366  // transformName - the Transform name.
   367  // filter - restricts the set of items returned.
   368  // orderby - specifies the by which the result collection should be ordered.
   369  func (client JobsClient) List(ctx context.Context, resourceGroupName string, accountName string, transformName string, filter string, orderby string) (result JobCollectionPage, err error) {
   370  	if tracing.IsEnabled() {
   371  		ctx = tracing.StartSpan(ctx, fqdn+"/JobsClient.List")
   372  		defer func() {
   373  			sc := -1
   374  			if result.jc.Response.Response != nil {
   375  				sc = result.jc.Response.Response.StatusCode
   376  			}
   377  			tracing.EndSpan(ctx, sc, err)
   378  		}()
   379  	}
   380  	result.fn = client.listNextResults
   381  	req, err := client.ListPreparer(ctx, resourceGroupName, accountName, transformName, filter, orderby)
   382  	if err != nil {
   383  		err = autorest.NewErrorWithError(err, "media.JobsClient", "List", nil, "Failure preparing request")
   384  		return
   385  	}
   386  
   387  	resp, err := client.ListSender(req)
   388  	if err != nil {
   389  		result.jc.Response = autorest.Response{Response: resp}
   390  		err = autorest.NewErrorWithError(err, "media.JobsClient", "List", resp, "Failure sending request")
   391  		return
   392  	}
   393  
   394  	result.jc, err = client.ListResponder(resp)
   395  	if err != nil {
   396  		err = autorest.NewErrorWithError(err, "media.JobsClient", "List", resp, "Failure responding to request")
   397  		return
   398  	}
   399  	if result.jc.hasNextLink() && result.jc.IsEmpty() {
   400  		err = result.NextWithContext(ctx)
   401  		return
   402  	}
   403  
   404  	return
   405  }
   406  
   407  // ListPreparer prepares the List request.
   408  func (client JobsClient) ListPreparer(ctx context.Context, resourceGroupName string, accountName string, transformName string, filter string, orderby string) (*http.Request, error) {
   409  	pathParameters := map[string]interface{}{
   410  		"accountName":       autorest.Encode("path", accountName),
   411  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   412  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   413  		"transformName":     autorest.Encode("path", transformName),
   414  	}
   415  
   416  	const APIVersion = "2018-07-01"
   417  	queryParameters := map[string]interface{}{
   418  		"api-version": APIVersion,
   419  	}
   420  	if len(filter) > 0 {
   421  		queryParameters["$filter"] = autorest.Encode("query", filter)
   422  	}
   423  	if len(orderby) > 0 {
   424  		queryParameters["$orderby"] = autorest.Encode("query", orderby)
   425  	}
   426  
   427  	preparer := autorest.CreatePreparer(
   428  		autorest.AsGet(),
   429  		autorest.WithBaseURL(client.BaseURI),
   430  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}/jobs", pathParameters),
   431  		autorest.WithQueryParameters(queryParameters))
   432  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   433  }
   434  
   435  // ListSender sends the List request. The method will close the
   436  // http.Response Body if it receives an error.
   437  func (client JobsClient) ListSender(req *http.Request) (*http.Response, error) {
   438  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   439  }
   440  
   441  // ListResponder handles the response to the List request. The method always
   442  // closes the http.Response Body.
   443  func (client JobsClient) ListResponder(resp *http.Response) (result JobCollection, err error) {
   444  	err = autorest.Respond(
   445  		resp,
   446  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   447  		autorest.ByUnmarshallingJSON(&result),
   448  		autorest.ByClosing())
   449  	result.Response = autorest.Response{Response: resp}
   450  	return
   451  }
   452  
   453  // listNextResults retrieves the next set of results, if any.
   454  func (client JobsClient) listNextResults(ctx context.Context, lastResults JobCollection) (result JobCollection, err error) {
   455  	req, err := lastResults.jobCollectionPreparer(ctx)
   456  	if err != nil {
   457  		return result, autorest.NewErrorWithError(err, "media.JobsClient", "listNextResults", nil, "Failure preparing next results request")
   458  	}
   459  	if req == nil {
   460  		return
   461  	}
   462  	resp, err := client.ListSender(req)
   463  	if err != nil {
   464  		result.Response = autorest.Response{Response: resp}
   465  		return result, autorest.NewErrorWithError(err, "media.JobsClient", "listNextResults", resp, "Failure sending next results request")
   466  	}
   467  	result, err = client.ListResponder(resp)
   468  	if err != nil {
   469  		err = autorest.NewErrorWithError(err, "media.JobsClient", "listNextResults", resp, "Failure responding to next results request")
   470  	}
   471  	return
   472  }
   473  
   474  // ListComplete enumerates all values, automatically crossing page boundaries as required.
   475  func (client JobsClient) ListComplete(ctx context.Context, resourceGroupName string, accountName string, transformName string, filter string, orderby string) (result JobCollectionIterator, err error) {
   476  	if tracing.IsEnabled() {
   477  		ctx = tracing.StartSpan(ctx, fqdn+"/JobsClient.List")
   478  		defer func() {
   479  			sc := -1
   480  			if result.Response().Response.Response != nil {
   481  				sc = result.page.Response().Response.Response.StatusCode
   482  			}
   483  			tracing.EndSpan(ctx, sc, err)
   484  		}()
   485  	}
   486  	result.page, err = client.List(ctx, resourceGroupName, accountName, transformName, filter, orderby)
   487  	return
   488  }
   489  
   490  // Update update is only supported for description and priority. Updating Priority will take effect when the Job state
   491  // is Queued or Scheduled and depending on the timing the priority update may be ignored.
   492  // Parameters:
   493  // resourceGroupName - the name of the resource group within the Azure subscription.
   494  // accountName - the Media Services account name.
   495  // transformName - the Transform name.
   496  // jobName - the Job name.
   497  // parameters - the request parameters
   498  func (client JobsClient) Update(ctx context.Context, resourceGroupName string, accountName string, transformName string, jobName string, parameters Job) (result Job, err error) {
   499  	if tracing.IsEnabled() {
   500  		ctx = tracing.StartSpan(ctx, fqdn+"/JobsClient.Update")
   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.UpdatePreparer(ctx, resourceGroupName, accountName, transformName, jobName, parameters)
   510  	if err != nil {
   511  		err = autorest.NewErrorWithError(err, "media.JobsClient", "Update", nil, "Failure preparing request")
   512  		return
   513  	}
   514  
   515  	resp, err := client.UpdateSender(req)
   516  	if err != nil {
   517  		result.Response = autorest.Response{Response: resp}
   518  		err = autorest.NewErrorWithError(err, "media.JobsClient", "Update", resp, "Failure sending request")
   519  		return
   520  	}
   521  
   522  	result, err = client.UpdateResponder(resp)
   523  	if err != nil {
   524  		err = autorest.NewErrorWithError(err, "media.JobsClient", "Update", resp, "Failure responding to request")
   525  		return
   526  	}
   527  
   528  	return
   529  }
   530  
   531  // UpdatePreparer prepares the Update request.
   532  func (client JobsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, transformName string, jobName string, parameters Job) (*http.Request, error) {
   533  	pathParameters := map[string]interface{}{
   534  		"accountName":       autorest.Encode("path", accountName),
   535  		"jobName":           autorest.Encode("path", jobName),
   536  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   537  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   538  		"transformName":     autorest.Encode("path", transformName),
   539  	}
   540  
   541  	const APIVersion = "2018-07-01"
   542  	queryParameters := map[string]interface{}{
   543  		"api-version": APIVersion,
   544  	}
   545  
   546  	preparer := autorest.CreatePreparer(
   547  		autorest.AsContentType("application/json; charset=utf-8"),
   548  		autorest.AsPatch(),
   549  		autorest.WithBaseURL(client.BaseURI),
   550  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}/jobs/{jobName}", pathParameters),
   551  		autorest.WithJSON(parameters),
   552  		autorest.WithQueryParameters(queryParameters))
   553  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   554  }
   555  
   556  // UpdateSender sends the Update request. The method will close the
   557  // http.Response Body if it receives an error.
   558  func (client JobsClient) UpdateSender(req *http.Request) (*http.Response, error) {
   559  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   560  }
   561  
   562  // UpdateResponder handles the response to the Update request. The method always
   563  // closes the http.Response Body.
   564  func (client JobsClient) UpdateResponder(resp *http.Response) (result Job, err error) {
   565  	err = autorest.Respond(
   566  		resp,
   567  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   568  		autorest.ByUnmarshallingJSON(&result),
   569  		autorest.ByClosing())
   570  	result.Response = autorest.Response{Response: resp}
   571  	return
   572  }
   573  

View as plain text