...

Source file src/github.com/Azure/azure-sdk-for-go/services/preview/devtestlabs/mgmt/2015-05-21-preview/dtl/schedule.go

Documentation: github.com/Azure/azure-sdk-for-go/services/preview/devtestlabs/mgmt/2015-05-21-preview/dtl

     1  package dtl
     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  // ScheduleClient is the azure DevTest Labs REST API version 2015-05-21-preview.
    18  type ScheduleClient struct {
    19  	BaseClient
    20  }
    21  
    22  // NewScheduleClient creates an instance of the ScheduleClient client.
    23  func NewScheduleClient(subscriptionID string) ScheduleClient {
    24  	return NewScheduleClientWithBaseURI(DefaultBaseURI, subscriptionID)
    25  }
    26  
    27  // NewScheduleClientWithBaseURI creates an instance of the ScheduleClient client using a custom endpoint.  Use this
    28  // when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
    29  func NewScheduleClientWithBaseURI(baseURI string, subscriptionID string) ScheduleClient {
    30  	return ScheduleClient{NewWithBaseURI(baseURI, subscriptionID)}
    31  }
    32  
    33  // CreateOrUpdateResource create or replace an existing schedule. This operation can take a while to complete.
    34  // Parameters:
    35  // resourceGroupName - the name of the resource group.
    36  // labName - the name of the lab.
    37  // name - the name of the schedule.
    38  func (client ScheduleClient) CreateOrUpdateResource(ctx context.Context, resourceGroupName string, labName string, name string, schedule Schedule) (result ScheduleCreateOrUpdateResourceFuture, err error) {
    39  	if tracing.IsEnabled() {
    40  		ctx = tracing.StartSpan(ctx, fqdn+"/ScheduleClient.CreateOrUpdateResource")
    41  		defer func() {
    42  			sc := -1
    43  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
    44  				sc = result.FutureAPI.Response().StatusCode
    45  			}
    46  			tracing.EndSpan(ctx, sc, err)
    47  		}()
    48  	}
    49  	req, err := client.CreateOrUpdateResourcePreparer(ctx, resourceGroupName, labName, name, schedule)
    50  	if err != nil {
    51  		err = autorest.NewErrorWithError(err, "dtl.ScheduleClient", "CreateOrUpdateResource", nil, "Failure preparing request")
    52  		return
    53  	}
    54  
    55  	result, err = client.CreateOrUpdateResourceSender(req)
    56  	if err != nil {
    57  		err = autorest.NewErrorWithError(err, "dtl.ScheduleClient", "CreateOrUpdateResource", result.Response(), "Failure sending request")
    58  		return
    59  	}
    60  
    61  	return
    62  }
    63  
    64  // CreateOrUpdateResourcePreparer prepares the CreateOrUpdateResource request.
    65  func (client ScheduleClient) CreateOrUpdateResourcePreparer(ctx context.Context, resourceGroupName string, labName string, name string, schedule Schedule) (*http.Request, error) {
    66  	pathParameters := map[string]interface{}{
    67  		"labName":           autorest.Encode("path", labName),
    68  		"name":              autorest.Encode("path", name),
    69  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
    70  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
    71  	}
    72  
    73  	const APIVersion = "2015-05-21-preview"
    74  	queryParameters := map[string]interface{}{
    75  		"api-version": APIVersion,
    76  	}
    77  
    78  	preparer := autorest.CreatePreparer(
    79  		autorest.AsContentType("application/json; charset=utf-8"),
    80  		autorest.AsPut(),
    81  		autorest.WithBaseURL(client.BaseURI),
    82  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/schedules/{name}", pathParameters),
    83  		autorest.WithJSON(schedule),
    84  		autorest.WithQueryParameters(queryParameters))
    85  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    86  }
    87  
    88  // CreateOrUpdateResourceSender sends the CreateOrUpdateResource request. The method will close the
    89  // http.Response Body if it receives an error.
    90  func (client ScheduleClient) CreateOrUpdateResourceSender(req *http.Request) (future ScheduleCreateOrUpdateResourceFuture, err error) {
    91  	var resp *http.Response
    92  	future.FutureAPI = &azure.Future{}
    93  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
    94  	if err != nil {
    95  		return
    96  	}
    97  	var azf azure.Future
    98  	azf, err = azure.NewFutureFromResponse(resp)
    99  	future.FutureAPI = &azf
   100  	future.Result = future.result
   101  	return
   102  }
   103  
   104  // CreateOrUpdateResourceResponder handles the response to the CreateOrUpdateResource request. The method always
   105  // closes the http.Response Body.
   106  func (client ScheduleClient) CreateOrUpdateResourceResponder(resp *http.Response) (result Schedule, err error) {
   107  	err = autorest.Respond(
   108  		resp,
   109  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
   110  		autorest.ByUnmarshallingJSON(&result),
   111  		autorest.ByClosing())
   112  	result.Response = autorest.Response{Response: resp}
   113  	return
   114  }
   115  
   116  // DeleteResource delete schedule. This operation can take a while to complete.
   117  // Parameters:
   118  // resourceGroupName - the name of the resource group.
   119  // labName - the name of the lab.
   120  // name - the name of the schedule.
   121  func (client ScheduleClient) DeleteResource(ctx context.Context, resourceGroupName string, labName string, name string) (result ScheduleDeleteResourceFuture, err error) {
   122  	if tracing.IsEnabled() {
   123  		ctx = tracing.StartSpan(ctx, fqdn+"/ScheduleClient.DeleteResource")
   124  		defer func() {
   125  			sc := -1
   126  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   127  				sc = result.FutureAPI.Response().StatusCode
   128  			}
   129  			tracing.EndSpan(ctx, sc, err)
   130  		}()
   131  	}
   132  	req, err := client.DeleteResourcePreparer(ctx, resourceGroupName, labName, name)
   133  	if err != nil {
   134  		err = autorest.NewErrorWithError(err, "dtl.ScheduleClient", "DeleteResource", nil, "Failure preparing request")
   135  		return
   136  	}
   137  
   138  	result, err = client.DeleteResourceSender(req)
   139  	if err != nil {
   140  		err = autorest.NewErrorWithError(err, "dtl.ScheduleClient", "DeleteResource", result.Response(), "Failure sending request")
   141  		return
   142  	}
   143  
   144  	return
   145  }
   146  
   147  // DeleteResourcePreparer prepares the DeleteResource request.
   148  func (client ScheduleClient) DeleteResourcePreparer(ctx context.Context, resourceGroupName string, labName string, name string) (*http.Request, error) {
   149  	pathParameters := map[string]interface{}{
   150  		"labName":           autorest.Encode("path", labName),
   151  		"name":              autorest.Encode("path", name),
   152  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   153  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   154  	}
   155  
   156  	const APIVersion = "2015-05-21-preview"
   157  	queryParameters := map[string]interface{}{
   158  		"api-version": APIVersion,
   159  	}
   160  
   161  	preparer := autorest.CreatePreparer(
   162  		autorest.AsDelete(),
   163  		autorest.WithBaseURL(client.BaseURI),
   164  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/schedules/{name}", pathParameters),
   165  		autorest.WithQueryParameters(queryParameters))
   166  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   167  }
   168  
   169  // DeleteResourceSender sends the DeleteResource request. The method will close the
   170  // http.Response Body if it receives an error.
   171  func (client ScheduleClient) DeleteResourceSender(req *http.Request) (future ScheduleDeleteResourceFuture, err error) {
   172  	var resp *http.Response
   173  	future.FutureAPI = &azure.Future{}
   174  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   175  	if err != nil {
   176  		return
   177  	}
   178  	var azf azure.Future
   179  	azf, err = azure.NewFutureFromResponse(resp)
   180  	future.FutureAPI = &azf
   181  	future.Result = future.result
   182  	return
   183  }
   184  
   185  // DeleteResourceResponder handles the response to the DeleteResource request. The method always
   186  // closes the http.Response Body.
   187  func (client ScheduleClient) DeleteResourceResponder(resp *http.Response) (result autorest.Response, err error) {
   188  	err = autorest.Respond(
   189  		resp,
   190  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   191  		autorest.ByClosing())
   192  	result.Response = resp
   193  	return
   194  }
   195  
   196  // Execute execute a schedule. This operation can take a while to complete.
   197  // Parameters:
   198  // resourceGroupName - the name of the resource group.
   199  // labName - the name of the lab.
   200  // name - the name of the schedule.
   201  func (client ScheduleClient) Execute(ctx context.Context, resourceGroupName string, labName string, name string) (result ScheduleExecuteFuture, err error) {
   202  	if tracing.IsEnabled() {
   203  		ctx = tracing.StartSpan(ctx, fqdn+"/ScheduleClient.Execute")
   204  		defer func() {
   205  			sc := -1
   206  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   207  				sc = result.FutureAPI.Response().StatusCode
   208  			}
   209  			tracing.EndSpan(ctx, sc, err)
   210  		}()
   211  	}
   212  	req, err := client.ExecutePreparer(ctx, resourceGroupName, labName, name)
   213  	if err != nil {
   214  		err = autorest.NewErrorWithError(err, "dtl.ScheduleClient", "Execute", nil, "Failure preparing request")
   215  		return
   216  	}
   217  
   218  	result, err = client.ExecuteSender(req)
   219  	if err != nil {
   220  		err = autorest.NewErrorWithError(err, "dtl.ScheduleClient", "Execute", result.Response(), "Failure sending request")
   221  		return
   222  	}
   223  
   224  	return
   225  }
   226  
   227  // ExecutePreparer prepares the Execute request.
   228  func (client ScheduleClient) ExecutePreparer(ctx context.Context, resourceGroupName string, labName string, name string) (*http.Request, error) {
   229  	pathParameters := map[string]interface{}{
   230  		"labName":           autorest.Encode("path", labName),
   231  		"name":              autorest.Encode("path", name),
   232  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   233  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   234  	}
   235  
   236  	const APIVersion = "2015-05-21-preview"
   237  	queryParameters := map[string]interface{}{
   238  		"api-version": APIVersion,
   239  	}
   240  
   241  	preparer := autorest.CreatePreparer(
   242  		autorest.AsPost(),
   243  		autorest.WithBaseURL(client.BaseURI),
   244  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/schedules/{name}/execute", pathParameters),
   245  		autorest.WithQueryParameters(queryParameters))
   246  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   247  }
   248  
   249  // ExecuteSender sends the Execute request. The method will close the
   250  // http.Response Body if it receives an error.
   251  func (client ScheduleClient) ExecuteSender(req *http.Request) (future ScheduleExecuteFuture, err error) {
   252  	var resp *http.Response
   253  	future.FutureAPI = &azure.Future{}
   254  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   255  	if err != nil {
   256  		return
   257  	}
   258  	var azf azure.Future
   259  	azf, err = azure.NewFutureFromResponse(resp)
   260  	future.FutureAPI = &azf
   261  	future.Result = future.result
   262  	return
   263  }
   264  
   265  // ExecuteResponder handles the response to the Execute request. The method always
   266  // closes the http.Response Body.
   267  func (client ScheduleClient) ExecuteResponder(resp *http.Response) (result autorest.Response, err error) {
   268  	err = autorest.Respond(
   269  		resp,
   270  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   271  		autorest.ByClosing())
   272  	result.Response = resp
   273  	return
   274  }
   275  
   276  // GetResource get schedule.
   277  // Parameters:
   278  // resourceGroupName - the name of the resource group.
   279  // labName - the name of the lab.
   280  // name - the name of the schedule.
   281  func (client ScheduleClient) GetResource(ctx context.Context, resourceGroupName string, labName string, name string) (result Schedule, err error) {
   282  	if tracing.IsEnabled() {
   283  		ctx = tracing.StartSpan(ctx, fqdn+"/ScheduleClient.GetResource")
   284  		defer func() {
   285  			sc := -1
   286  			if result.Response.Response != nil {
   287  				sc = result.Response.Response.StatusCode
   288  			}
   289  			tracing.EndSpan(ctx, sc, err)
   290  		}()
   291  	}
   292  	req, err := client.GetResourcePreparer(ctx, resourceGroupName, labName, name)
   293  	if err != nil {
   294  		err = autorest.NewErrorWithError(err, "dtl.ScheduleClient", "GetResource", nil, "Failure preparing request")
   295  		return
   296  	}
   297  
   298  	resp, err := client.GetResourceSender(req)
   299  	if err != nil {
   300  		result.Response = autorest.Response{Response: resp}
   301  		err = autorest.NewErrorWithError(err, "dtl.ScheduleClient", "GetResource", resp, "Failure sending request")
   302  		return
   303  	}
   304  
   305  	result, err = client.GetResourceResponder(resp)
   306  	if err != nil {
   307  		err = autorest.NewErrorWithError(err, "dtl.ScheduleClient", "GetResource", resp, "Failure responding to request")
   308  		return
   309  	}
   310  
   311  	return
   312  }
   313  
   314  // GetResourcePreparer prepares the GetResource request.
   315  func (client ScheduleClient) GetResourcePreparer(ctx context.Context, resourceGroupName string, labName string, name string) (*http.Request, error) {
   316  	pathParameters := map[string]interface{}{
   317  		"labName":           autorest.Encode("path", labName),
   318  		"name":              autorest.Encode("path", name),
   319  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   320  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   321  	}
   322  
   323  	const APIVersion = "2015-05-21-preview"
   324  	queryParameters := map[string]interface{}{
   325  		"api-version": APIVersion,
   326  	}
   327  
   328  	preparer := autorest.CreatePreparer(
   329  		autorest.AsGet(),
   330  		autorest.WithBaseURL(client.BaseURI),
   331  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/schedules/{name}", pathParameters),
   332  		autorest.WithQueryParameters(queryParameters))
   333  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   334  }
   335  
   336  // GetResourceSender sends the GetResource request. The method will close the
   337  // http.Response Body if it receives an error.
   338  func (client ScheduleClient) GetResourceSender(req *http.Request) (*http.Response, error) {
   339  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   340  }
   341  
   342  // GetResourceResponder handles the response to the GetResource request. The method always
   343  // closes the http.Response Body.
   344  func (client ScheduleClient) GetResourceResponder(resp *http.Response) (result Schedule, err error) {
   345  	err = autorest.Respond(
   346  		resp,
   347  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   348  		autorest.ByUnmarshallingJSON(&result),
   349  		autorest.ByClosing())
   350  	result.Response = autorest.Response{Response: resp}
   351  	return
   352  }
   353  
   354  // List list schedules.
   355  // Parameters:
   356  // resourceGroupName - the name of the resource group.
   357  // labName - the name of the lab.
   358  // filter - the filter to apply on the operation.
   359  func (client ScheduleClient) List(ctx context.Context, resourceGroupName string, labName string, filter string, top *int32, orderBy string) (result ResponseWithContinuationSchedulePage, err error) {
   360  	if tracing.IsEnabled() {
   361  		ctx = tracing.StartSpan(ctx, fqdn+"/ScheduleClient.List")
   362  		defer func() {
   363  			sc := -1
   364  			if result.rwcs.Response.Response != nil {
   365  				sc = result.rwcs.Response.Response.StatusCode
   366  			}
   367  			tracing.EndSpan(ctx, sc, err)
   368  		}()
   369  	}
   370  	result.fn = client.listNextResults
   371  	req, err := client.ListPreparer(ctx, resourceGroupName, labName, filter, top, orderBy)
   372  	if err != nil {
   373  		err = autorest.NewErrorWithError(err, "dtl.ScheduleClient", "List", nil, "Failure preparing request")
   374  		return
   375  	}
   376  
   377  	resp, err := client.ListSender(req)
   378  	if err != nil {
   379  		result.rwcs.Response = autorest.Response{Response: resp}
   380  		err = autorest.NewErrorWithError(err, "dtl.ScheduleClient", "List", resp, "Failure sending request")
   381  		return
   382  	}
   383  
   384  	result.rwcs, err = client.ListResponder(resp)
   385  	if err != nil {
   386  		err = autorest.NewErrorWithError(err, "dtl.ScheduleClient", "List", resp, "Failure responding to request")
   387  		return
   388  	}
   389  	if result.rwcs.hasNextLink() && result.rwcs.IsEmpty() {
   390  		err = result.NextWithContext(ctx)
   391  		return
   392  	}
   393  
   394  	return
   395  }
   396  
   397  // ListPreparer prepares the List request.
   398  func (client ScheduleClient) ListPreparer(ctx context.Context, resourceGroupName string, labName string, filter string, top *int32, orderBy string) (*http.Request, error) {
   399  	pathParameters := map[string]interface{}{
   400  		"labName":           autorest.Encode("path", labName),
   401  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   402  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   403  	}
   404  
   405  	const APIVersion = "2015-05-21-preview"
   406  	queryParameters := map[string]interface{}{
   407  		"api-version": APIVersion,
   408  	}
   409  	if len(filter) > 0 {
   410  		queryParameters["$filter"] = autorest.Encode("query", filter)
   411  	}
   412  	if top != nil {
   413  		queryParameters["$top"] = autorest.Encode("query", *top)
   414  	}
   415  	if len(orderBy) > 0 {
   416  		queryParameters["$orderBy"] = autorest.Encode("query", orderBy)
   417  	}
   418  
   419  	preparer := autorest.CreatePreparer(
   420  		autorest.AsGet(),
   421  		autorest.WithBaseURL(client.BaseURI),
   422  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/schedules", pathParameters),
   423  		autorest.WithQueryParameters(queryParameters))
   424  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   425  }
   426  
   427  // ListSender sends the List request. The method will close the
   428  // http.Response Body if it receives an error.
   429  func (client ScheduleClient) ListSender(req *http.Request) (*http.Response, error) {
   430  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   431  }
   432  
   433  // ListResponder handles the response to the List request. The method always
   434  // closes the http.Response Body.
   435  func (client ScheduleClient) ListResponder(resp *http.Response) (result ResponseWithContinuationSchedule, err error) {
   436  	err = autorest.Respond(
   437  		resp,
   438  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   439  		autorest.ByUnmarshallingJSON(&result),
   440  		autorest.ByClosing())
   441  	result.Response = autorest.Response{Response: resp}
   442  	return
   443  }
   444  
   445  // listNextResults retrieves the next set of results, if any.
   446  func (client ScheduleClient) listNextResults(ctx context.Context, lastResults ResponseWithContinuationSchedule) (result ResponseWithContinuationSchedule, err error) {
   447  	req, err := lastResults.responseWithContinuationSchedulePreparer(ctx)
   448  	if err != nil {
   449  		return result, autorest.NewErrorWithError(err, "dtl.ScheduleClient", "listNextResults", nil, "Failure preparing next results request")
   450  	}
   451  	if req == nil {
   452  		return
   453  	}
   454  	resp, err := client.ListSender(req)
   455  	if err != nil {
   456  		result.Response = autorest.Response{Response: resp}
   457  		return result, autorest.NewErrorWithError(err, "dtl.ScheduleClient", "listNextResults", resp, "Failure sending next results request")
   458  	}
   459  	result, err = client.ListResponder(resp)
   460  	if err != nil {
   461  		err = autorest.NewErrorWithError(err, "dtl.ScheduleClient", "listNextResults", resp, "Failure responding to next results request")
   462  	}
   463  	return
   464  }
   465  
   466  // ListComplete enumerates all values, automatically crossing page boundaries as required.
   467  func (client ScheduleClient) ListComplete(ctx context.Context, resourceGroupName string, labName string, filter string, top *int32, orderBy string) (result ResponseWithContinuationScheduleIterator, err error) {
   468  	if tracing.IsEnabled() {
   469  		ctx = tracing.StartSpan(ctx, fqdn+"/ScheduleClient.List")
   470  		defer func() {
   471  			sc := -1
   472  			if result.Response().Response.Response != nil {
   473  				sc = result.page.Response().Response.Response.StatusCode
   474  			}
   475  			tracing.EndSpan(ctx, sc, err)
   476  		}()
   477  	}
   478  	result.page, err = client.List(ctx, resourceGroupName, labName, filter, top, orderBy)
   479  	return
   480  }
   481  
   482  // PatchResource modify properties of schedules.
   483  // Parameters:
   484  // resourceGroupName - the name of the resource group.
   485  // labName - the name of the lab.
   486  // name - the name of the schedule.
   487  func (client ScheduleClient) PatchResource(ctx context.Context, resourceGroupName string, labName string, name string, schedule Schedule) (result Schedule, err error) {
   488  	if tracing.IsEnabled() {
   489  		ctx = tracing.StartSpan(ctx, fqdn+"/ScheduleClient.PatchResource")
   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.PatchResourcePreparer(ctx, resourceGroupName, labName, name, schedule)
   499  	if err != nil {
   500  		err = autorest.NewErrorWithError(err, "dtl.ScheduleClient", "PatchResource", nil, "Failure preparing request")
   501  		return
   502  	}
   503  
   504  	resp, err := client.PatchResourceSender(req)
   505  	if err != nil {
   506  		result.Response = autorest.Response{Response: resp}
   507  		err = autorest.NewErrorWithError(err, "dtl.ScheduleClient", "PatchResource", resp, "Failure sending request")
   508  		return
   509  	}
   510  
   511  	result, err = client.PatchResourceResponder(resp)
   512  	if err != nil {
   513  		err = autorest.NewErrorWithError(err, "dtl.ScheduleClient", "PatchResource", resp, "Failure responding to request")
   514  		return
   515  	}
   516  
   517  	return
   518  }
   519  
   520  // PatchResourcePreparer prepares the PatchResource request.
   521  func (client ScheduleClient) PatchResourcePreparer(ctx context.Context, resourceGroupName string, labName string, name string, schedule Schedule) (*http.Request, error) {
   522  	pathParameters := map[string]interface{}{
   523  		"labName":           autorest.Encode("path", labName),
   524  		"name":              autorest.Encode("path", name),
   525  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   526  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   527  	}
   528  
   529  	const APIVersion = "2015-05-21-preview"
   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.AsPatch(),
   537  		autorest.WithBaseURL(client.BaseURI),
   538  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/schedules/{name}", pathParameters),
   539  		autorest.WithJSON(schedule),
   540  		autorest.WithQueryParameters(queryParameters))
   541  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   542  }
   543  
   544  // PatchResourceSender sends the PatchResource request. The method will close the
   545  // http.Response Body if it receives an error.
   546  func (client ScheduleClient) PatchResourceSender(req *http.Request) (*http.Response, error) {
   547  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   548  }
   549  
   550  // PatchResourceResponder handles the response to the PatchResource request. The method always
   551  // closes the http.Response Body.
   552  func (client ScheduleClient) PatchResourceResponder(resp *http.Response) (result Schedule, 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  

View as plain text