...

Source file src/github.com/Azure/azure-sdk-for-go/services/devtestlabs/mgmt/2016-05-15/dtl/labs.go

Documentation: github.com/Azure/azure-sdk-for-go/services/devtestlabs/mgmt/2016-05-15/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/autorest/validation"
    14  	"github.com/Azure/go-autorest/tracing"
    15  	"net/http"
    16  )
    17  
    18  // LabsClient is the the DevTest Labs Client.
    19  type LabsClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewLabsClient creates an instance of the LabsClient client.
    24  func NewLabsClient(subscriptionID string) LabsClient {
    25  	return NewLabsClientWithBaseURI(DefaultBaseURI, subscriptionID)
    26  }
    27  
    28  // NewLabsClientWithBaseURI creates an instance of the LabsClient 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 NewLabsClientWithBaseURI(baseURI string, subscriptionID string) LabsClient {
    31  	return LabsClient{NewWithBaseURI(baseURI, subscriptionID)}
    32  }
    33  
    34  // ClaimAnyVM claim a random claimable virtual machine in the lab. This operation can take a while to complete.
    35  // Parameters:
    36  // resourceGroupName - the name of the resource group.
    37  // name - the name of the lab.
    38  func (client LabsClient) ClaimAnyVM(ctx context.Context, resourceGroupName string, name string) (result LabsClaimAnyVMFuture, err error) {
    39  	if tracing.IsEnabled() {
    40  		ctx = tracing.StartSpan(ctx, fqdn+"/LabsClient.ClaimAnyVM")
    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.ClaimAnyVMPreparer(ctx, resourceGroupName, name)
    50  	if err != nil {
    51  		err = autorest.NewErrorWithError(err, "dtl.LabsClient", "ClaimAnyVM", nil, "Failure preparing request")
    52  		return
    53  	}
    54  
    55  	result, err = client.ClaimAnyVMSender(req)
    56  	if err != nil {
    57  		err = autorest.NewErrorWithError(err, "dtl.LabsClient", "ClaimAnyVM", result.Response(), "Failure sending request")
    58  		return
    59  	}
    60  
    61  	return
    62  }
    63  
    64  // ClaimAnyVMPreparer prepares the ClaimAnyVM request.
    65  func (client LabsClient) ClaimAnyVMPreparer(ctx context.Context, resourceGroupName string, name string) (*http.Request, error) {
    66  	pathParameters := map[string]interface{}{
    67  		"name":              autorest.Encode("path", name),
    68  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
    69  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
    70  	}
    71  
    72  	const APIVersion = "2016-05-15"
    73  	queryParameters := map[string]interface{}{
    74  		"api-version": APIVersion,
    75  	}
    76  
    77  	preparer := autorest.CreatePreparer(
    78  		autorest.AsPost(),
    79  		autorest.WithBaseURL(client.BaseURI),
    80  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}/claimAnyVm", pathParameters),
    81  		autorest.WithQueryParameters(queryParameters))
    82  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    83  }
    84  
    85  // ClaimAnyVMSender sends the ClaimAnyVM request. The method will close the
    86  // http.Response Body if it receives an error.
    87  func (client LabsClient) ClaimAnyVMSender(req *http.Request) (future LabsClaimAnyVMFuture, err error) {
    88  	var resp *http.Response
    89  	future.FutureAPI = &azure.Future{}
    90  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
    91  	if err != nil {
    92  		return
    93  	}
    94  	var azf azure.Future
    95  	azf, err = azure.NewFutureFromResponse(resp)
    96  	future.FutureAPI = &azf
    97  	future.Result = future.result
    98  	return
    99  }
   100  
   101  // ClaimAnyVMResponder handles the response to the ClaimAnyVM request. The method always
   102  // closes the http.Response Body.
   103  func (client LabsClient) ClaimAnyVMResponder(resp *http.Response) (result autorest.Response, err error) {
   104  	err = autorest.Respond(
   105  		resp,
   106  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   107  		autorest.ByClosing())
   108  	result.Response = resp
   109  	return
   110  }
   111  
   112  // CreateEnvironment create virtual machines in a lab. This operation can take a while to complete.
   113  // Parameters:
   114  // resourceGroupName - the name of the resource group.
   115  // name - the name of the lab.
   116  // labVirtualMachineCreationParameter - properties for creating a virtual machine.
   117  func (client LabsClient) CreateEnvironment(ctx context.Context, resourceGroupName string, name string, labVirtualMachineCreationParameter LabVirtualMachineCreationParameter) (result LabsCreateEnvironmentFuture, err error) {
   118  	if tracing.IsEnabled() {
   119  		ctx = tracing.StartSpan(ctx, fqdn+"/LabsClient.CreateEnvironment")
   120  		defer func() {
   121  			sc := -1
   122  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   123  				sc = result.FutureAPI.Response().StatusCode
   124  			}
   125  			tracing.EndSpan(ctx, sc, err)
   126  		}()
   127  	}
   128  	if err := validation.Validate([]validation.Validation{
   129  		{TargetValue: labVirtualMachineCreationParameter,
   130  			Constraints: []validation.Constraint{{Target: "labVirtualMachineCreationParameter.LabVirtualMachineCreationParameterProperties", Name: validation.Null, Rule: false,
   131  				Chain: []validation.Constraint{{Target: "labVirtualMachineCreationParameter.LabVirtualMachineCreationParameterProperties.ApplicableSchedule", Name: validation.Null, Rule: false,
   132  					Chain: []validation.Constraint{{Target: "labVirtualMachineCreationParameter.LabVirtualMachineCreationParameterProperties.ApplicableSchedule.ApplicableScheduleProperties", Name: validation.Null, Rule: true,
   133  						Chain: []validation.Constraint{{Target: "labVirtualMachineCreationParameter.LabVirtualMachineCreationParameterProperties.ApplicableSchedule.ApplicableScheduleProperties.LabVmsShutdown", Name: validation.Null, Rule: false,
   134  							Chain: []validation.Constraint{{Target: "labVirtualMachineCreationParameter.LabVirtualMachineCreationParameterProperties.ApplicableSchedule.ApplicableScheduleProperties.LabVmsShutdown.ScheduleProperties", Name: validation.Null, Rule: true, Chain: nil}}},
   135  							{Target: "labVirtualMachineCreationParameter.LabVirtualMachineCreationParameterProperties.ApplicableSchedule.ApplicableScheduleProperties.LabVmsStartup", Name: validation.Null, Rule: false,
   136  								Chain: []validation.Constraint{{Target: "labVirtualMachineCreationParameter.LabVirtualMachineCreationParameterProperties.ApplicableSchedule.ApplicableScheduleProperties.LabVmsStartup.ScheduleProperties", Name: validation.Null, Rule: true, Chain: nil}}},
   137  						}},
   138  					}},
   139  				}}}}}); err != nil {
   140  		return result, validation.NewError("dtl.LabsClient", "CreateEnvironment", err.Error())
   141  	}
   142  
   143  	req, err := client.CreateEnvironmentPreparer(ctx, resourceGroupName, name, labVirtualMachineCreationParameter)
   144  	if err != nil {
   145  		err = autorest.NewErrorWithError(err, "dtl.LabsClient", "CreateEnvironment", nil, "Failure preparing request")
   146  		return
   147  	}
   148  
   149  	result, err = client.CreateEnvironmentSender(req)
   150  	if err != nil {
   151  		err = autorest.NewErrorWithError(err, "dtl.LabsClient", "CreateEnvironment", result.Response(), "Failure sending request")
   152  		return
   153  	}
   154  
   155  	return
   156  }
   157  
   158  // CreateEnvironmentPreparer prepares the CreateEnvironment request.
   159  func (client LabsClient) CreateEnvironmentPreparer(ctx context.Context, resourceGroupName string, name string, labVirtualMachineCreationParameter LabVirtualMachineCreationParameter) (*http.Request, error) {
   160  	pathParameters := map[string]interface{}{
   161  		"name":              autorest.Encode("path", name),
   162  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   163  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   164  	}
   165  
   166  	const APIVersion = "2016-05-15"
   167  	queryParameters := map[string]interface{}{
   168  		"api-version": APIVersion,
   169  	}
   170  
   171  	preparer := autorest.CreatePreparer(
   172  		autorest.AsContentType("application/json; charset=utf-8"),
   173  		autorest.AsPost(),
   174  		autorest.WithBaseURL(client.BaseURI),
   175  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}/createEnvironment", pathParameters),
   176  		autorest.WithJSON(labVirtualMachineCreationParameter),
   177  		autorest.WithQueryParameters(queryParameters))
   178  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   179  }
   180  
   181  // CreateEnvironmentSender sends the CreateEnvironment request. The method will close the
   182  // http.Response Body if it receives an error.
   183  func (client LabsClient) CreateEnvironmentSender(req *http.Request) (future LabsCreateEnvironmentFuture, err error) {
   184  	var resp *http.Response
   185  	future.FutureAPI = &azure.Future{}
   186  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   187  	if err != nil {
   188  		return
   189  	}
   190  	var azf azure.Future
   191  	azf, err = azure.NewFutureFromResponse(resp)
   192  	future.FutureAPI = &azf
   193  	future.Result = future.result
   194  	return
   195  }
   196  
   197  // CreateEnvironmentResponder handles the response to the CreateEnvironment request. The method always
   198  // closes the http.Response Body.
   199  func (client LabsClient) CreateEnvironmentResponder(resp *http.Response) (result autorest.Response, err error) {
   200  	err = autorest.Respond(
   201  		resp,
   202  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   203  		autorest.ByClosing())
   204  	result.Response = resp
   205  	return
   206  }
   207  
   208  // CreateOrUpdate create or replace an existing lab. This operation can take a while to complete.
   209  // Parameters:
   210  // resourceGroupName - the name of the resource group.
   211  // name - the name of the lab.
   212  // lab - a lab.
   213  func (client LabsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, name string, lab Lab) (result LabsCreateOrUpdateFuture, err error) {
   214  	if tracing.IsEnabled() {
   215  		ctx = tracing.StartSpan(ctx, fqdn+"/LabsClient.CreateOrUpdate")
   216  		defer func() {
   217  			sc := -1
   218  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   219  				sc = result.FutureAPI.Response().StatusCode
   220  			}
   221  			tracing.EndSpan(ctx, sc, err)
   222  		}()
   223  	}
   224  	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, name, lab)
   225  	if err != nil {
   226  		err = autorest.NewErrorWithError(err, "dtl.LabsClient", "CreateOrUpdate", nil, "Failure preparing request")
   227  		return
   228  	}
   229  
   230  	result, err = client.CreateOrUpdateSender(req)
   231  	if err != nil {
   232  		err = autorest.NewErrorWithError(err, "dtl.LabsClient", "CreateOrUpdate", result.Response(), "Failure sending request")
   233  		return
   234  	}
   235  
   236  	return
   237  }
   238  
   239  // CreateOrUpdatePreparer prepares the CreateOrUpdate request.
   240  func (client LabsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, name string, lab Lab) (*http.Request, error) {
   241  	pathParameters := map[string]interface{}{
   242  		"name":              autorest.Encode("path", name),
   243  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   244  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   245  	}
   246  
   247  	const APIVersion = "2016-05-15"
   248  	queryParameters := map[string]interface{}{
   249  		"api-version": APIVersion,
   250  	}
   251  
   252  	preparer := autorest.CreatePreparer(
   253  		autorest.AsContentType("application/json; charset=utf-8"),
   254  		autorest.AsPut(),
   255  		autorest.WithBaseURL(client.BaseURI),
   256  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}", pathParameters),
   257  		autorest.WithJSON(lab),
   258  		autorest.WithQueryParameters(queryParameters))
   259  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   260  }
   261  
   262  // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
   263  // http.Response Body if it receives an error.
   264  func (client LabsClient) CreateOrUpdateSender(req *http.Request) (future LabsCreateOrUpdateFuture, err error) {
   265  	var resp *http.Response
   266  	future.FutureAPI = &azure.Future{}
   267  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   268  	if err != nil {
   269  		return
   270  	}
   271  	var azf azure.Future
   272  	azf, err = azure.NewFutureFromResponse(resp)
   273  	future.FutureAPI = &azf
   274  	future.Result = future.result
   275  	return
   276  }
   277  
   278  // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
   279  // closes the http.Response Body.
   280  func (client LabsClient) CreateOrUpdateResponder(resp *http.Response) (result Lab, err error) {
   281  	err = autorest.Respond(
   282  		resp,
   283  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
   284  		autorest.ByUnmarshallingJSON(&result),
   285  		autorest.ByClosing())
   286  	result.Response = autorest.Response{Response: resp}
   287  	return
   288  }
   289  
   290  // Delete delete lab. This operation can take a while to complete.
   291  // Parameters:
   292  // resourceGroupName - the name of the resource group.
   293  // name - the name of the lab.
   294  func (client LabsClient) Delete(ctx context.Context, resourceGroupName string, name string) (result LabsDeleteFuture, err error) {
   295  	if tracing.IsEnabled() {
   296  		ctx = tracing.StartSpan(ctx, fqdn+"/LabsClient.Delete")
   297  		defer func() {
   298  			sc := -1
   299  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   300  				sc = result.FutureAPI.Response().StatusCode
   301  			}
   302  			tracing.EndSpan(ctx, sc, err)
   303  		}()
   304  	}
   305  	req, err := client.DeletePreparer(ctx, resourceGroupName, name)
   306  	if err != nil {
   307  		err = autorest.NewErrorWithError(err, "dtl.LabsClient", "Delete", nil, "Failure preparing request")
   308  		return
   309  	}
   310  
   311  	result, err = client.DeleteSender(req)
   312  	if err != nil {
   313  		err = autorest.NewErrorWithError(err, "dtl.LabsClient", "Delete", result.Response(), "Failure sending request")
   314  		return
   315  	}
   316  
   317  	return
   318  }
   319  
   320  // DeletePreparer prepares the Delete request.
   321  func (client LabsClient) DeletePreparer(ctx context.Context, resourceGroupName string, name string) (*http.Request, error) {
   322  	pathParameters := map[string]interface{}{
   323  		"name":              autorest.Encode("path", name),
   324  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   325  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   326  	}
   327  
   328  	const APIVersion = "2016-05-15"
   329  	queryParameters := map[string]interface{}{
   330  		"api-version": APIVersion,
   331  	}
   332  
   333  	preparer := autorest.CreatePreparer(
   334  		autorest.AsDelete(),
   335  		autorest.WithBaseURL(client.BaseURI),
   336  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}", pathParameters),
   337  		autorest.WithQueryParameters(queryParameters))
   338  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   339  }
   340  
   341  // DeleteSender sends the Delete request. The method will close the
   342  // http.Response Body if it receives an error.
   343  func (client LabsClient) DeleteSender(req *http.Request) (future LabsDeleteFuture, err error) {
   344  	var resp *http.Response
   345  	future.FutureAPI = &azure.Future{}
   346  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   347  	if err != nil {
   348  		return
   349  	}
   350  	var azf azure.Future
   351  	azf, err = azure.NewFutureFromResponse(resp)
   352  	future.FutureAPI = &azf
   353  	future.Result = future.result
   354  	return
   355  }
   356  
   357  // DeleteResponder handles the response to the Delete request. The method always
   358  // closes the http.Response Body.
   359  func (client LabsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
   360  	err = autorest.Respond(
   361  		resp,
   362  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   363  		autorest.ByClosing())
   364  	result.Response = resp
   365  	return
   366  }
   367  
   368  // ExportResourceUsage exports the lab resource usage into a storage account This operation can take a while to
   369  // complete.
   370  // Parameters:
   371  // resourceGroupName - the name of the resource group.
   372  // name - the name of the lab.
   373  // exportResourceUsageParameters - the parameters of the export operation.
   374  func (client LabsClient) ExportResourceUsage(ctx context.Context, resourceGroupName string, name string, exportResourceUsageParameters ExportResourceUsageParameters) (result LabsExportResourceUsageFuture, err error) {
   375  	if tracing.IsEnabled() {
   376  		ctx = tracing.StartSpan(ctx, fqdn+"/LabsClient.ExportResourceUsage")
   377  		defer func() {
   378  			sc := -1
   379  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   380  				sc = result.FutureAPI.Response().StatusCode
   381  			}
   382  			tracing.EndSpan(ctx, sc, err)
   383  		}()
   384  	}
   385  	req, err := client.ExportResourceUsagePreparer(ctx, resourceGroupName, name, exportResourceUsageParameters)
   386  	if err != nil {
   387  		err = autorest.NewErrorWithError(err, "dtl.LabsClient", "ExportResourceUsage", nil, "Failure preparing request")
   388  		return
   389  	}
   390  
   391  	result, err = client.ExportResourceUsageSender(req)
   392  	if err != nil {
   393  		err = autorest.NewErrorWithError(err, "dtl.LabsClient", "ExportResourceUsage", result.Response(), "Failure sending request")
   394  		return
   395  	}
   396  
   397  	return
   398  }
   399  
   400  // ExportResourceUsagePreparer prepares the ExportResourceUsage request.
   401  func (client LabsClient) ExportResourceUsagePreparer(ctx context.Context, resourceGroupName string, name string, exportResourceUsageParameters ExportResourceUsageParameters) (*http.Request, error) {
   402  	pathParameters := map[string]interface{}{
   403  		"name":              autorest.Encode("path", name),
   404  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   405  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   406  	}
   407  
   408  	const APIVersion = "2016-05-15"
   409  	queryParameters := map[string]interface{}{
   410  		"api-version": APIVersion,
   411  	}
   412  
   413  	preparer := autorest.CreatePreparer(
   414  		autorest.AsContentType("application/json; charset=utf-8"),
   415  		autorest.AsPost(),
   416  		autorest.WithBaseURL(client.BaseURI),
   417  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}/exportResourceUsage", pathParameters),
   418  		autorest.WithJSON(exportResourceUsageParameters),
   419  		autorest.WithQueryParameters(queryParameters))
   420  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   421  }
   422  
   423  // ExportResourceUsageSender sends the ExportResourceUsage request. The method will close the
   424  // http.Response Body if it receives an error.
   425  func (client LabsClient) ExportResourceUsageSender(req *http.Request) (future LabsExportResourceUsageFuture, err error) {
   426  	var resp *http.Response
   427  	future.FutureAPI = &azure.Future{}
   428  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   429  	if err != nil {
   430  		return
   431  	}
   432  	var azf azure.Future
   433  	azf, err = azure.NewFutureFromResponse(resp)
   434  	future.FutureAPI = &azf
   435  	future.Result = future.result
   436  	return
   437  }
   438  
   439  // ExportResourceUsageResponder handles the response to the ExportResourceUsage request. The method always
   440  // closes the http.Response Body.
   441  func (client LabsClient) ExportResourceUsageResponder(resp *http.Response) (result autorest.Response, err error) {
   442  	err = autorest.Respond(
   443  		resp,
   444  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   445  		autorest.ByClosing())
   446  	result.Response = resp
   447  	return
   448  }
   449  
   450  // GenerateUploadURI generate a URI for uploading custom disk images to a Lab.
   451  // Parameters:
   452  // resourceGroupName - the name of the resource group.
   453  // name - the name of the lab.
   454  // generateUploadURIParameter - properties for generating an upload URI.
   455  func (client LabsClient) GenerateUploadURI(ctx context.Context, resourceGroupName string, name string, generateUploadURIParameter GenerateUploadURIParameter) (result GenerateUploadURIResponse, err error) {
   456  	if tracing.IsEnabled() {
   457  		ctx = tracing.StartSpan(ctx, fqdn+"/LabsClient.GenerateUploadURI")
   458  		defer func() {
   459  			sc := -1
   460  			if result.Response.Response != nil {
   461  				sc = result.Response.Response.StatusCode
   462  			}
   463  			tracing.EndSpan(ctx, sc, err)
   464  		}()
   465  	}
   466  	req, err := client.GenerateUploadURIPreparer(ctx, resourceGroupName, name, generateUploadURIParameter)
   467  	if err != nil {
   468  		err = autorest.NewErrorWithError(err, "dtl.LabsClient", "GenerateUploadURI", nil, "Failure preparing request")
   469  		return
   470  	}
   471  
   472  	resp, err := client.GenerateUploadURISender(req)
   473  	if err != nil {
   474  		result.Response = autorest.Response{Response: resp}
   475  		err = autorest.NewErrorWithError(err, "dtl.LabsClient", "GenerateUploadURI", resp, "Failure sending request")
   476  		return
   477  	}
   478  
   479  	result, err = client.GenerateUploadURIResponder(resp)
   480  	if err != nil {
   481  		err = autorest.NewErrorWithError(err, "dtl.LabsClient", "GenerateUploadURI", resp, "Failure responding to request")
   482  		return
   483  	}
   484  
   485  	return
   486  }
   487  
   488  // GenerateUploadURIPreparer prepares the GenerateUploadURI request.
   489  func (client LabsClient) GenerateUploadURIPreparer(ctx context.Context, resourceGroupName string, name string, generateUploadURIParameter GenerateUploadURIParameter) (*http.Request, error) {
   490  	pathParameters := map[string]interface{}{
   491  		"name":              autorest.Encode("path", name),
   492  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   493  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   494  	}
   495  
   496  	const APIVersion = "2016-05-15"
   497  	queryParameters := map[string]interface{}{
   498  		"api-version": APIVersion,
   499  	}
   500  
   501  	preparer := autorest.CreatePreparer(
   502  		autorest.AsContentType("application/json; charset=utf-8"),
   503  		autorest.AsPost(),
   504  		autorest.WithBaseURL(client.BaseURI),
   505  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}/generateUploadUri", pathParameters),
   506  		autorest.WithJSON(generateUploadURIParameter),
   507  		autorest.WithQueryParameters(queryParameters))
   508  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   509  }
   510  
   511  // GenerateUploadURISender sends the GenerateUploadURI request. The method will close the
   512  // http.Response Body if it receives an error.
   513  func (client LabsClient) GenerateUploadURISender(req *http.Request) (*http.Response, error) {
   514  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   515  }
   516  
   517  // GenerateUploadURIResponder handles the response to the GenerateUploadURI request. The method always
   518  // closes the http.Response Body.
   519  func (client LabsClient) GenerateUploadURIResponder(resp *http.Response) (result GenerateUploadURIResponse, err error) {
   520  	err = autorest.Respond(
   521  		resp,
   522  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   523  		autorest.ByUnmarshallingJSON(&result),
   524  		autorest.ByClosing())
   525  	result.Response = autorest.Response{Response: resp}
   526  	return
   527  }
   528  
   529  // Get get lab.
   530  // Parameters:
   531  // resourceGroupName - the name of the resource group.
   532  // name - the name of the lab.
   533  // expand - specify the $expand query. Example: 'properties($select=defaultStorageAccount)'
   534  func (client LabsClient) Get(ctx context.Context, resourceGroupName string, name string, expand string) (result Lab, err error) {
   535  	if tracing.IsEnabled() {
   536  		ctx = tracing.StartSpan(ctx, fqdn+"/LabsClient.Get")
   537  		defer func() {
   538  			sc := -1
   539  			if result.Response.Response != nil {
   540  				sc = result.Response.Response.StatusCode
   541  			}
   542  			tracing.EndSpan(ctx, sc, err)
   543  		}()
   544  	}
   545  	req, err := client.GetPreparer(ctx, resourceGroupName, name, expand)
   546  	if err != nil {
   547  		err = autorest.NewErrorWithError(err, "dtl.LabsClient", "Get", nil, "Failure preparing request")
   548  		return
   549  	}
   550  
   551  	resp, err := client.GetSender(req)
   552  	if err != nil {
   553  		result.Response = autorest.Response{Response: resp}
   554  		err = autorest.NewErrorWithError(err, "dtl.LabsClient", "Get", resp, "Failure sending request")
   555  		return
   556  	}
   557  
   558  	result, err = client.GetResponder(resp)
   559  	if err != nil {
   560  		err = autorest.NewErrorWithError(err, "dtl.LabsClient", "Get", resp, "Failure responding to request")
   561  		return
   562  	}
   563  
   564  	return
   565  }
   566  
   567  // GetPreparer prepares the Get request.
   568  func (client LabsClient) GetPreparer(ctx context.Context, resourceGroupName string, name string, expand string) (*http.Request, error) {
   569  	pathParameters := map[string]interface{}{
   570  		"name":              autorest.Encode("path", name),
   571  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   572  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   573  	}
   574  
   575  	const APIVersion = "2016-05-15"
   576  	queryParameters := map[string]interface{}{
   577  		"api-version": APIVersion,
   578  	}
   579  	if len(expand) > 0 {
   580  		queryParameters["$expand"] = autorest.Encode("query", expand)
   581  	}
   582  
   583  	preparer := autorest.CreatePreparer(
   584  		autorest.AsGet(),
   585  		autorest.WithBaseURL(client.BaseURI),
   586  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}", pathParameters),
   587  		autorest.WithQueryParameters(queryParameters))
   588  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   589  }
   590  
   591  // GetSender sends the Get request. The method will close the
   592  // http.Response Body if it receives an error.
   593  func (client LabsClient) GetSender(req *http.Request) (*http.Response, error) {
   594  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   595  }
   596  
   597  // GetResponder handles the response to the Get request. The method always
   598  // closes the http.Response Body.
   599  func (client LabsClient) GetResponder(resp *http.Response) (result Lab, err error) {
   600  	err = autorest.Respond(
   601  		resp,
   602  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   603  		autorest.ByUnmarshallingJSON(&result),
   604  		autorest.ByClosing())
   605  	result.Response = autorest.Response{Response: resp}
   606  	return
   607  }
   608  
   609  // ListByResourceGroup list labs in a resource group.
   610  // Parameters:
   611  // resourceGroupName - the name of the resource group.
   612  // expand - specify the $expand query. Example: 'properties($select=defaultStorageAccount)'
   613  // filter - the filter to apply to the operation.
   614  // top - the maximum number of resources to return from the operation.
   615  // orderby - the ordering expression for the results, using OData notation.
   616  func (client LabsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, expand string, filter string, top *int32, orderby string) (result ResponseWithContinuationLabPage, err error) {
   617  	if tracing.IsEnabled() {
   618  		ctx = tracing.StartSpan(ctx, fqdn+"/LabsClient.ListByResourceGroup")
   619  		defer func() {
   620  			sc := -1
   621  			if result.rwcl.Response.Response != nil {
   622  				sc = result.rwcl.Response.Response.StatusCode
   623  			}
   624  			tracing.EndSpan(ctx, sc, err)
   625  		}()
   626  	}
   627  	result.fn = client.listByResourceGroupNextResults
   628  	req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName, expand, filter, top, orderby)
   629  	if err != nil {
   630  		err = autorest.NewErrorWithError(err, "dtl.LabsClient", "ListByResourceGroup", nil, "Failure preparing request")
   631  		return
   632  	}
   633  
   634  	resp, err := client.ListByResourceGroupSender(req)
   635  	if err != nil {
   636  		result.rwcl.Response = autorest.Response{Response: resp}
   637  		err = autorest.NewErrorWithError(err, "dtl.LabsClient", "ListByResourceGroup", resp, "Failure sending request")
   638  		return
   639  	}
   640  
   641  	result.rwcl, err = client.ListByResourceGroupResponder(resp)
   642  	if err != nil {
   643  		err = autorest.NewErrorWithError(err, "dtl.LabsClient", "ListByResourceGroup", resp, "Failure responding to request")
   644  		return
   645  	}
   646  	if result.rwcl.hasNextLink() && result.rwcl.IsEmpty() {
   647  		err = result.NextWithContext(ctx)
   648  		return
   649  	}
   650  
   651  	return
   652  }
   653  
   654  // ListByResourceGroupPreparer prepares the ListByResourceGroup request.
   655  func (client LabsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string, expand string, filter string, top *int32, orderby string) (*http.Request, error) {
   656  	pathParameters := map[string]interface{}{
   657  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   658  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   659  	}
   660  
   661  	const APIVersion = "2016-05-15"
   662  	queryParameters := map[string]interface{}{
   663  		"api-version": APIVersion,
   664  	}
   665  	if len(expand) > 0 {
   666  		queryParameters["$expand"] = autorest.Encode("query", expand)
   667  	}
   668  	if len(filter) > 0 {
   669  		queryParameters["$filter"] = autorest.Encode("query", filter)
   670  	}
   671  	if top != nil {
   672  		queryParameters["$top"] = autorest.Encode("query", *top)
   673  	}
   674  	if len(orderby) > 0 {
   675  		queryParameters["$orderby"] = autorest.Encode("query", orderby)
   676  	}
   677  
   678  	preparer := autorest.CreatePreparer(
   679  		autorest.AsGet(),
   680  		autorest.WithBaseURL(client.BaseURI),
   681  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs", pathParameters),
   682  		autorest.WithQueryParameters(queryParameters))
   683  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   684  }
   685  
   686  // ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the
   687  // http.Response Body if it receives an error.
   688  func (client LabsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
   689  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   690  }
   691  
   692  // ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always
   693  // closes the http.Response Body.
   694  func (client LabsClient) ListByResourceGroupResponder(resp *http.Response) (result ResponseWithContinuationLab, err error) {
   695  	err = autorest.Respond(
   696  		resp,
   697  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   698  		autorest.ByUnmarshallingJSON(&result),
   699  		autorest.ByClosing())
   700  	result.Response = autorest.Response{Response: resp}
   701  	return
   702  }
   703  
   704  // listByResourceGroupNextResults retrieves the next set of results, if any.
   705  func (client LabsClient) listByResourceGroupNextResults(ctx context.Context, lastResults ResponseWithContinuationLab) (result ResponseWithContinuationLab, err error) {
   706  	req, err := lastResults.responseWithContinuationLabPreparer(ctx)
   707  	if err != nil {
   708  		return result, autorest.NewErrorWithError(err, "dtl.LabsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
   709  	}
   710  	if req == nil {
   711  		return
   712  	}
   713  	resp, err := client.ListByResourceGroupSender(req)
   714  	if err != nil {
   715  		result.Response = autorest.Response{Response: resp}
   716  		return result, autorest.NewErrorWithError(err, "dtl.LabsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
   717  	}
   718  	result, err = client.ListByResourceGroupResponder(resp)
   719  	if err != nil {
   720  		err = autorest.NewErrorWithError(err, "dtl.LabsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
   721  	}
   722  	return
   723  }
   724  
   725  // ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
   726  func (client LabsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string, expand string, filter string, top *int32, orderby string) (result ResponseWithContinuationLabIterator, err error) {
   727  	if tracing.IsEnabled() {
   728  		ctx = tracing.StartSpan(ctx, fqdn+"/LabsClient.ListByResourceGroup")
   729  		defer func() {
   730  			sc := -1
   731  			if result.Response().Response.Response != nil {
   732  				sc = result.page.Response().Response.Response.StatusCode
   733  			}
   734  			tracing.EndSpan(ctx, sc, err)
   735  		}()
   736  	}
   737  	result.page, err = client.ListByResourceGroup(ctx, resourceGroupName, expand, filter, top, orderby)
   738  	return
   739  }
   740  
   741  // ListBySubscription list labs in a subscription.
   742  // Parameters:
   743  // expand - specify the $expand query. Example: 'properties($select=defaultStorageAccount)'
   744  // filter - the filter to apply to the operation.
   745  // top - the maximum number of resources to return from the operation.
   746  // orderby - the ordering expression for the results, using OData notation.
   747  func (client LabsClient) ListBySubscription(ctx context.Context, expand string, filter string, top *int32, orderby string) (result ResponseWithContinuationLabPage, err error) {
   748  	if tracing.IsEnabled() {
   749  		ctx = tracing.StartSpan(ctx, fqdn+"/LabsClient.ListBySubscription")
   750  		defer func() {
   751  			sc := -1
   752  			if result.rwcl.Response.Response != nil {
   753  				sc = result.rwcl.Response.Response.StatusCode
   754  			}
   755  			tracing.EndSpan(ctx, sc, err)
   756  		}()
   757  	}
   758  	result.fn = client.listBySubscriptionNextResults
   759  	req, err := client.ListBySubscriptionPreparer(ctx, expand, filter, top, orderby)
   760  	if err != nil {
   761  		err = autorest.NewErrorWithError(err, "dtl.LabsClient", "ListBySubscription", nil, "Failure preparing request")
   762  		return
   763  	}
   764  
   765  	resp, err := client.ListBySubscriptionSender(req)
   766  	if err != nil {
   767  		result.rwcl.Response = autorest.Response{Response: resp}
   768  		err = autorest.NewErrorWithError(err, "dtl.LabsClient", "ListBySubscription", resp, "Failure sending request")
   769  		return
   770  	}
   771  
   772  	result.rwcl, err = client.ListBySubscriptionResponder(resp)
   773  	if err != nil {
   774  		err = autorest.NewErrorWithError(err, "dtl.LabsClient", "ListBySubscription", resp, "Failure responding to request")
   775  		return
   776  	}
   777  	if result.rwcl.hasNextLink() && result.rwcl.IsEmpty() {
   778  		err = result.NextWithContext(ctx)
   779  		return
   780  	}
   781  
   782  	return
   783  }
   784  
   785  // ListBySubscriptionPreparer prepares the ListBySubscription request.
   786  func (client LabsClient) ListBySubscriptionPreparer(ctx context.Context, expand string, filter string, top *int32, orderby string) (*http.Request, error) {
   787  	pathParameters := map[string]interface{}{
   788  		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
   789  	}
   790  
   791  	const APIVersion = "2016-05-15"
   792  	queryParameters := map[string]interface{}{
   793  		"api-version": APIVersion,
   794  	}
   795  	if len(expand) > 0 {
   796  		queryParameters["$expand"] = autorest.Encode("query", expand)
   797  	}
   798  	if len(filter) > 0 {
   799  		queryParameters["$filter"] = autorest.Encode("query", filter)
   800  	}
   801  	if top != nil {
   802  		queryParameters["$top"] = autorest.Encode("query", *top)
   803  	}
   804  	if len(orderby) > 0 {
   805  		queryParameters["$orderby"] = autorest.Encode("query", orderby)
   806  	}
   807  
   808  	preparer := autorest.CreatePreparer(
   809  		autorest.AsGet(),
   810  		autorest.WithBaseURL(client.BaseURI),
   811  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DevTestLab/labs", pathParameters),
   812  		autorest.WithQueryParameters(queryParameters))
   813  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   814  }
   815  
   816  // ListBySubscriptionSender sends the ListBySubscription request. The method will close the
   817  // http.Response Body if it receives an error.
   818  func (client LabsClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) {
   819  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   820  }
   821  
   822  // ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always
   823  // closes the http.Response Body.
   824  func (client LabsClient) ListBySubscriptionResponder(resp *http.Response) (result ResponseWithContinuationLab, err error) {
   825  	err = autorest.Respond(
   826  		resp,
   827  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   828  		autorest.ByUnmarshallingJSON(&result),
   829  		autorest.ByClosing())
   830  	result.Response = autorest.Response{Response: resp}
   831  	return
   832  }
   833  
   834  // listBySubscriptionNextResults retrieves the next set of results, if any.
   835  func (client LabsClient) listBySubscriptionNextResults(ctx context.Context, lastResults ResponseWithContinuationLab) (result ResponseWithContinuationLab, err error) {
   836  	req, err := lastResults.responseWithContinuationLabPreparer(ctx)
   837  	if err != nil {
   838  		return result, autorest.NewErrorWithError(err, "dtl.LabsClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request")
   839  	}
   840  	if req == nil {
   841  		return
   842  	}
   843  	resp, err := client.ListBySubscriptionSender(req)
   844  	if err != nil {
   845  		result.Response = autorest.Response{Response: resp}
   846  		return result, autorest.NewErrorWithError(err, "dtl.LabsClient", "listBySubscriptionNextResults", resp, "Failure sending next results request")
   847  	}
   848  	result, err = client.ListBySubscriptionResponder(resp)
   849  	if err != nil {
   850  		err = autorest.NewErrorWithError(err, "dtl.LabsClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request")
   851  	}
   852  	return
   853  }
   854  
   855  // ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required.
   856  func (client LabsClient) ListBySubscriptionComplete(ctx context.Context, expand string, filter string, top *int32, orderby string) (result ResponseWithContinuationLabIterator, err error) {
   857  	if tracing.IsEnabled() {
   858  		ctx = tracing.StartSpan(ctx, fqdn+"/LabsClient.ListBySubscription")
   859  		defer func() {
   860  			sc := -1
   861  			if result.Response().Response.Response != nil {
   862  				sc = result.page.Response().Response.Response.StatusCode
   863  			}
   864  			tracing.EndSpan(ctx, sc, err)
   865  		}()
   866  	}
   867  	result.page, err = client.ListBySubscription(ctx, expand, filter, top, orderby)
   868  	return
   869  }
   870  
   871  // ListVhds list disk images available for custom image creation.
   872  // Parameters:
   873  // resourceGroupName - the name of the resource group.
   874  // name - the name of the lab.
   875  func (client LabsClient) ListVhds(ctx context.Context, resourceGroupName string, name string) (result ResponseWithContinuationLabVhdPage, err error) {
   876  	if tracing.IsEnabled() {
   877  		ctx = tracing.StartSpan(ctx, fqdn+"/LabsClient.ListVhds")
   878  		defer func() {
   879  			sc := -1
   880  			if result.rwclv.Response.Response != nil {
   881  				sc = result.rwclv.Response.Response.StatusCode
   882  			}
   883  			tracing.EndSpan(ctx, sc, err)
   884  		}()
   885  	}
   886  	result.fn = client.listVhdsNextResults
   887  	req, err := client.ListVhdsPreparer(ctx, resourceGroupName, name)
   888  	if err != nil {
   889  		err = autorest.NewErrorWithError(err, "dtl.LabsClient", "ListVhds", nil, "Failure preparing request")
   890  		return
   891  	}
   892  
   893  	resp, err := client.ListVhdsSender(req)
   894  	if err != nil {
   895  		result.rwclv.Response = autorest.Response{Response: resp}
   896  		err = autorest.NewErrorWithError(err, "dtl.LabsClient", "ListVhds", resp, "Failure sending request")
   897  		return
   898  	}
   899  
   900  	result.rwclv, err = client.ListVhdsResponder(resp)
   901  	if err != nil {
   902  		err = autorest.NewErrorWithError(err, "dtl.LabsClient", "ListVhds", resp, "Failure responding to request")
   903  		return
   904  	}
   905  	if result.rwclv.hasNextLink() && result.rwclv.IsEmpty() {
   906  		err = result.NextWithContext(ctx)
   907  		return
   908  	}
   909  
   910  	return
   911  }
   912  
   913  // ListVhdsPreparer prepares the ListVhds request.
   914  func (client LabsClient) ListVhdsPreparer(ctx context.Context, resourceGroupName string, name string) (*http.Request, error) {
   915  	pathParameters := map[string]interface{}{
   916  		"name":              autorest.Encode("path", name),
   917  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   918  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   919  	}
   920  
   921  	const APIVersion = "2016-05-15"
   922  	queryParameters := map[string]interface{}{
   923  		"api-version": APIVersion,
   924  	}
   925  
   926  	preparer := autorest.CreatePreparer(
   927  		autorest.AsPost(),
   928  		autorest.WithBaseURL(client.BaseURI),
   929  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}/listVhds", pathParameters),
   930  		autorest.WithQueryParameters(queryParameters))
   931  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   932  }
   933  
   934  // ListVhdsSender sends the ListVhds request. The method will close the
   935  // http.Response Body if it receives an error.
   936  func (client LabsClient) ListVhdsSender(req *http.Request) (*http.Response, error) {
   937  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   938  }
   939  
   940  // ListVhdsResponder handles the response to the ListVhds request. The method always
   941  // closes the http.Response Body.
   942  func (client LabsClient) ListVhdsResponder(resp *http.Response) (result ResponseWithContinuationLabVhd, err error) {
   943  	err = autorest.Respond(
   944  		resp,
   945  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   946  		autorest.ByUnmarshallingJSON(&result),
   947  		autorest.ByClosing())
   948  	result.Response = autorest.Response{Response: resp}
   949  	return
   950  }
   951  
   952  // listVhdsNextResults retrieves the next set of results, if any.
   953  func (client LabsClient) listVhdsNextResults(ctx context.Context, lastResults ResponseWithContinuationLabVhd) (result ResponseWithContinuationLabVhd, err error) {
   954  	req, err := lastResults.responseWithContinuationLabVhdPreparer(ctx)
   955  	if err != nil {
   956  		return result, autorest.NewErrorWithError(err, "dtl.LabsClient", "listVhdsNextResults", nil, "Failure preparing next results request")
   957  	}
   958  	if req == nil {
   959  		return
   960  	}
   961  	resp, err := client.ListVhdsSender(req)
   962  	if err != nil {
   963  		result.Response = autorest.Response{Response: resp}
   964  		return result, autorest.NewErrorWithError(err, "dtl.LabsClient", "listVhdsNextResults", resp, "Failure sending next results request")
   965  	}
   966  	result, err = client.ListVhdsResponder(resp)
   967  	if err != nil {
   968  		err = autorest.NewErrorWithError(err, "dtl.LabsClient", "listVhdsNextResults", resp, "Failure responding to next results request")
   969  	}
   970  	return
   971  }
   972  
   973  // ListVhdsComplete enumerates all values, automatically crossing page boundaries as required.
   974  func (client LabsClient) ListVhdsComplete(ctx context.Context, resourceGroupName string, name string) (result ResponseWithContinuationLabVhdIterator, err error) {
   975  	if tracing.IsEnabled() {
   976  		ctx = tracing.StartSpan(ctx, fqdn+"/LabsClient.ListVhds")
   977  		defer func() {
   978  			sc := -1
   979  			if result.Response().Response.Response != nil {
   980  				sc = result.page.Response().Response.Response.StatusCode
   981  			}
   982  			tracing.EndSpan(ctx, sc, err)
   983  		}()
   984  	}
   985  	result.page, err = client.ListVhds(ctx, resourceGroupName, name)
   986  	return
   987  }
   988  
   989  // Update modify properties of labs.
   990  // Parameters:
   991  // resourceGroupName - the name of the resource group.
   992  // name - the name of the lab.
   993  // lab - a lab.
   994  func (client LabsClient) Update(ctx context.Context, resourceGroupName string, name string, lab LabFragment) (result Lab, err error) {
   995  	if tracing.IsEnabled() {
   996  		ctx = tracing.StartSpan(ctx, fqdn+"/LabsClient.Update")
   997  		defer func() {
   998  			sc := -1
   999  			if result.Response.Response != nil {
  1000  				sc = result.Response.Response.StatusCode
  1001  			}
  1002  			tracing.EndSpan(ctx, sc, err)
  1003  		}()
  1004  	}
  1005  	req, err := client.UpdatePreparer(ctx, resourceGroupName, name, lab)
  1006  	if err != nil {
  1007  		err = autorest.NewErrorWithError(err, "dtl.LabsClient", "Update", nil, "Failure preparing request")
  1008  		return
  1009  	}
  1010  
  1011  	resp, err := client.UpdateSender(req)
  1012  	if err != nil {
  1013  		result.Response = autorest.Response{Response: resp}
  1014  		err = autorest.NewErrorWithError(err, "dtl.LabsClient", "Update", resp, "Failure sending request")
  1015  		return
  1016  	}
  1017  
  1018  	result, err = client.UpdateResponder(resp)
  1019  	if err != nil {
  1020  		err = autorest.NewErrorWithError(err, "dtl.LabsClient", "Update", resp, "Failure responding to request")
  1021  		return
  1022  	}
  1023  
  1024  	return
  1025  }
  1026  
  1027  // UpdatePreparer prepares the Update request.
  1028  func (client LabsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, name string, lab LabFragment) (*http.Request, error) {
  1029  	pathParameters := map[string]interface{}{
  1030  		"name":              autorest.Encode("path", name),
  1031  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
  1032  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
  1033  	}
  1034  
  1035  	const APIVersion = "2016-05-15"
  1036  	queryParameters := map[string]interface{}{
  1037  		"api-version": APIVersion,
  1038  	}
  1039  
  1040  	preparer := autorest.CreatePreparer(
  1041  		autorest.AsContentType("application/json; charset=utf-8"),
  1042  		autorest.AsPatch(),
  1043  		autorest.WithBaseURL(client.BaseURI),
  1044  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}", pathParameters),
  1045  		autorest.WithJSON(lab),
  1046  		autorest.WithQueryParameters(queryParameters))
  1047  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
  1048  }
  1049  
  1050  // UpdateSender sends the Update request. The method will close the
  1051  // http.Response Body if it receives an error.
  1052  func (client LabsClient) UpdateSender(req *http.Request) (*http.Response, error) {
  1053  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
  1054  }
  1055  
  1056  // UpdateResponder handles the response to the Update request. The method always
  1057  // closes the http.Response Body.
  1058  func (client LabsClient) UpdateResponder(resp *http.Response) (result Lab, err error) {
  1059  	err = autorest.Respond(
  1060  		resp,
  1061  		azure.WithErrorUnlessStatusCode(http.StatusOK),
  1062  		autorest.ByUnmarshallingJSON(&result),
  1063  		autorest.ByClosing())
  1064  	result.Response = autorest.Response{Response: resp}
  1065  	return
  1066  }
  1067  

View as plain text