...

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

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

View as plain text