...

Source file src/github.com/Azure/azure-sdk-for-go/services/devtestlabs/mgmt/2016-05-15/dtl/disks.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  // DisksClient is the the DevTest Labs Client.
    19  type DisksClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewDisksClient creates an instance of the DisksClient client.
    24  func NewDisksClient(subscriptionID string) DisksClient {
    25  	return NewDisksClientWithBaseURI(DefaultBaseURI, subscriptionID)
    26  }
    27  
    28  // NewDisksClientWithBaseURI creates an instance of the DisksClient 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 NewDisksClientWithBaseURI(baseURI string, subscriptionID string) DisksClient {
    31  	return DisksClient{NewWithBaseURI(baseURI, subscriptionID)}
    32  }
    33  
    34  // Attach attach and create the lease of the disk to the virtual machine. This operation can take a while to complete.
    35  // Parameters:
    36  // resourceGroupName - the name of the resource group.
    37  // labName - the name of the lab.
    38  // userName - the name of the user profile.
    39  // name - the name of the disk.
    40  // attachDiskProperties - properties of the disk to attach.
    41  func (client DisksClient) Attach(ctx context.Context, resourceGroupName string, labName string, userName string, name string, attachDiskProperties AttachDiskProperties) (result DisksAttachFuture, err error) {
    42  	if tracing.IsEnabled() {
    43  		ctx = tracing.StartSpan(ctx, fqdn+"/DisksClient.Attach")
    44  		defer func() {
    45  			sc := -1
    46  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
    47  				sc = result.FutureAPI.Response().StatusCode
    48  			}
    49  			tracing.EndSpan(ctx, sc, err)
    50  		}()
    51  	}
    52  	req, err := client.AttachPreparer(ctx, resourceGroupName, labName, userName, name, attachDiskProperties)
    53  	if err != nil {
    54  		err = autorest.NewErrorWithError(err, "dtl.DisksClient", "Attach", nil, "Failure preparing request")
    55  		return
    56  	}
    57  
    58  	result, err = client.AttachSender(req)
    59  	if err != nil {
    60  		err = autorest.NewErrorWithError(err, "dtl.DisksClient", "Attach", result.Response(), "Failure sending request")
    61  		return
    62  	}
    63  
    64  	return
    65  }
    66  
    67  // AttachPreparer prepares the Attach request.
    68  func (client DisksClient) AttachPreparer(ctx context.Context, resourceGroupName string, labName string, userName string, name string, attachDiskProperties AttachDiskProperties) (*http.Request, error) {
    69  	pathParameters := map[string]interface{}{
    70  		"labName":           autorest.Encode("path", labName),
    71  		"name":              autorest.Encode("path", name),
    72  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
    73  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
    74  		"userName":          autorest.Encode("path", userName),
    75  	}
    76  
    77  	const APIVersion = "2016-05-15"
    78  	queryParameters := map[string]interface{}{
    79  		"api-version": APIVersion,
    80  	}
    81  
    82  	preparer := autorest.CreatePreparer(
    83  		autorest.AsContentType("application/json; charset=utf-8"),
    84  		autorest.AsPost(),
    85  		autorest.WithBaseURL(client.BaseURI),
    86  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks/{name}/attach", pathParameters),
    87  		autorest.WithJSON(attachDiskProperties),
    88  		autorest.WithQueryParameters(queryParameters))
    89  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    90  }
    91  
    92  // AttachSender sends the Attach request. The method will close the
    93  // http.Response Body if it receives an error.
    94  func (client DisksClient) AttachSender(req *http.Request) (future DisksAttachFuture, err error) {
    95  	var resp *http.Response
    96  	future.FutureAPI = &azure.Future{}
    97  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
    98  	if err != nil {
    99  		return
   100  	}
   101  	var azf azure.Future
   102  	azf, err = azure.NewFutureFromResponse(resp)
   103  	future.FutureAPI = &azf
   104  	future.Result = future.result
   105  	return
   106  }
   107  
   108  // AttachResponder handles the response to the Attach request. The method always
   109  // closes the http.Response Body.
   110  func (client DisksClient) AttachResponder(resp *http.Response) (result autorest.Response, err error) {
   111  	err = autorest.Respond(
   112  		resp,
   113  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   114  		autorest.ByClosing())
   115  	result.Response = resp
   116  	return
   117  }
   118  
   119  // CreateOrUpdate create or replace an existing disk. This operation can take a while to complete.
   120  // Parameters:
   121  // resourceGroupName - the name of the resource group.
   122  // labName - the name of the lab.
   123  // userName - the name of the user profile.
   124  // name - the name of the disk.
   125  // disk - a Disk.
   126  func (client DisksClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, labName string, userName string, name string, disk Disk) (result DisksCreateOrUpdateFuture, err error) {
   127  	if tracing.IsEnabled() {
   128  		ctx = tracing.StartSpan(ctx, fqdn+"/DisksClient.CreateOrUpdate")
   129  		defer func() {
   130  			sc := -1
   131  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   132  				sc = result.FutureAPI.Response().StatusCode
   133  			}
   134  			tracing.EndSpan(ctx, sc, err)
   135  		}()
   136  	}
   137  	if err := validation.Validate([]validation.Validation{
   138  		{TargetValue: disk,
   139  			Constraints: []validation.Constraint{{Target: "disk.DiskProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
   140  		return result, validation.NewError("dtl.DisksClient", "CreateOrUpdate", err.Error())
   141  	}
   142  
   143  	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, labName, userName, name, disk)
   144  	if err != nil {
   145  		err = autorest.NewErrorWithError(err, "dtl.DisksClient", "CreateOrUpdate", nil, "Failure preparing request")
   146  		return
   147  	}
   148  
   149  	result, err = client.CreateOrUpdateSender(req)
   150  	if err != nil {
   151  		err = autorest.NewErrorWithError(err, "dtl.DisksClient", "CreateOrUpdate", result.Response(), "Failure sending request")
   152  		return
   153  	}
   154  
   155  	return
   156  }
   157  
   158  // CreateOrUpdatePreparer prepares the CreateOrUpdate request.
   159  func (client DisksClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, labName string, userName string, name string, disk Disk) (*http.Request, error) {
   160  	pathParameters := map[string]interface{}{
   161  		"labName":           autorest.Encode("path", labName),
   162  		"name":              autorest.Encode("path", name),
   163  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   164  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   165  		"userName":          autorest.Encode("path", userName),
   166  	}
   167  
   168  	const APIVersion = "2016-05-15"
   169  	queryParameters := map[string]interface{}{
   170  		"api-version": APIVersion,
   171  	}
   172  
   173  	preparer := autorest.CreatePreparer(
   174  		autorest.AsContentType("application/json; charset=utf-8"),
   175  		autorest.AsPut(),
   176  		autorest.WithBaseURL(client.BaseURI),
   177  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks/{name}", pathParameters),
   178  		autorest.WithJSON(disk),
   179  		autorest.WithQueryParameters(queryParameters))
   180  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   181  }
   182  
   183  // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
   184  // http.Response Body if it receives an error.
   185  func (client DisksClient) CreateOrUpdateSender(req *http.Request) (future DisksCreateOrUpdateFuture, err error) {
   186  	var resp *http.Response
   187  	future.FutureAPI = &azure.Future{}
   188  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   189  	if err != nil {
   190  		return
   191  	}
   192  	var azf azure.Future
   193  	azf, err = azure.NewFutureFromResponse(resp)
   194  	future.FutureAPI = &azf
   195  	future.Result = future.result
   196  	return
   197  }
   198  
   199  // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
   200  // closes the http.Response Body.
   201  func (client DisksClient) CreateOrUpdateResponder(resp *http.Response) (result Disk, err error) {
   202  	err = autorest.Respond(
   203  		resp,
   204  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
   205  		autorest.ByUnmarshallingJSON(&result),
   206  		autorest.ByClosing())
   207  	result.Response = autorest.Response{Response: resp}
   208  	return
   209  }
   210  
   211  // Delete delete disk. This operation can take a while to complete.
   212  // Parameters:
   213  // resourceGroupName - the name of the resource group.
   214  // labName - the name of the lab.
   215  // userName - the name of the user profile.
   216  // name - the name of the disk.
   217  func (client DisksClient) Delete(ctx context.Context, resourceGroupName string, labName string, userName string, name string) (result DisksDeleteFuture, err error) {
   218  	if tracing.IsEnabled() {
   219  		ctx = tracing.StartSpan(ctx, fqdn+"/DisksClient.Delete")
   220  		defer func() {
   221  			sc := -1
   222  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   223  				sc = result.FutureAPI.Response().StatusCode
   224  			}
   225  			tracing.EndSpan(ctx, sc, err)
   226  		}()
   227  	}
   228  	req, err := client.DeletePreparer(ctx, resourceGroupName, labName, userName, name)
   229  	if err != nil {
   230  		err = autorest.NewErrorWithError(err, "dtl.DisksClient", "Delete", nil, "Failure preparing request")
   231  		return
   232  	}
   233  
   234  	result, err = client.DeleteSender(req)
   235  	if err != nil {
   236  		err = autorest.NewErrorWithError(err, "dtl.DisksClient", "Delete", result.Response(), "Failure sending request")
   237  		return
   238  	}
   239  
   240  	return
   241  }
   242  
   243  // DeletePreparer prepares the Delete request.
   244  func (client DisksClient) DeletePreparer(ctx context.Context, resourceGroupName string, labName string, userName string, name string) (*http.Request, error) {
   245  	pathParameters := map[string]interface{}{
   246  		"labName":           autorest.Encode("path", labName),
   247  		"name":              autorest.Encode("path", name),
   248  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   249  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   250  		"userName":          autorest.Encode("path", userName),
   251  	}
   252  
   253  	const APIVersion = "2016-05-15"
   254  	queryParameters := map[string]interface{}{
   255  		"api-version": APIVersion,
   256  	}
   257  
   258  	preparer := autorest.CreatePreparer(
   259  		autorest.AsDelete(),
   260  		autorest.WithBaseURL(client.BaseURI),
   261  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks/{name}", pathParameters),
   262  		autorest.WithQueryParameters(queryParameters))
   263  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   264  }
   265  
   266  // DeleteSender sends the Delete request. The method will close the
   267  // http.Response Body if it receives an error.
   268  func (client DisksClient) DeleteSender(req *http.Request) (future DisksDeleteFuture, err error) {
   269  	var resp *http.Response
   270  	future.FutureAPI = &azure.Future{}
   271  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   272  	if err != nil {
   273  		return
   274  	}
   275  	var azf azure.Future
   276  	azf, err = azure.NewFutureFromResponse(resp)
   277  	future.FutureAPI = &azf
   278  	future.Result = future.result
   279  	return
   280  }
   281  
   282  // DeleteResponder handles the response to the Delete request. The method always
   283  // closes the http.Response Body.
   284  func (client DisksClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
   285  	err = autorest.Respond(
   286  		resp,
   287  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   288  		autorest.ByClosing())
   289  	result.Response = resp
   290  	return
   291  }
   292  
   293  // Detach detach and break the lease of the disk attached to the virtual machine. This operation can take a while to
   294  // complete.
   295  // Parameters:
   296  // resourceGroupName - the name of the resource group.
   297  // labName - the name of the lab.
   298  // userName - the name of the user profile.
   299  // name - the name of the disk.
   300  // detachDiskProperties - properties of the disk to detach.
   301  func (client DisksClient) Detach(ctx context.Context, resourceGroupName string, labName string, userName string, name string, detachDiskProperties DetachDiskProperties) (result DisksDetachFuture, err error) {
   302  	if tracing.IsEnabled() {
   303  		ctx = tracing.StartSpan(ctx, fqdn+"/DisksClient.Detach")
   304  		defer func() {
   305  			sc := -1
   306  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   307  				sc = result.FutureAPI.Response().StatusCode
   308  			}
   309  			tracing.EndSpan(ctx, sc, err)
   310  		}()
   311  	}
   312  	req, err := client.DetachPreparer(ctx, resourceGroupName, labName, userName, name, detachDiskProperties)
   313  	if err != nil {
   314  		err = autorest.NewErrorWithError(err, "dtl.DisksClient", "Detach", nil, "Failure preparing request")
   315  		return
   316  	}
   317  
   318  	result, err = client.DetachSender(req)
   319  	if err != nil {
   320  		err = autorest.NewErrorWithError(err, "dtl.DisksClient", "Detach", result.Response(), "Failure sending request")
   321  		return
   322  	}
   323  
   324  	return
   325  }
   326  
   327  // DetachPreparer prepares the Detach request.
   328  func (client DisksClient) DetachPreparer(ctx context.Context, resourceGroupName string, labName string, userName string, name string, detachDiskProperties DetachDiskProperties) (*http.Request, error) {
   329  	pathParameters := map[string]interface{}{
   330  		"labName":           autorest.Encode("path", labName),
   331  		"name":              autorest.Encode("path", name),
   332  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   333  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   334  		"userName":          autorest.Encode("path", userName),
   335  	}
   336  
   337  	const APIVersion = "2016-05-15"
   338  	queryParameters := map[string]interface{}{
   339  		"api-version": APIVersion,
   340  	}
   341  
   342  	preparer := autorest.CreatePreparer(
   343  		autorest.AsContentType("application/json; charset=utf-8"),
   344  		autorest.AsPost(),
   345  		autorest.WithBaseURL(client.BaseURI),
   346  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks/{name}/detach", pathParameters),
   347  		autorest.WithJSON(detachDiskProperties),
   348  		autorest.WithQueryParameters(queryParameters))
   349  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   350  }
   351  
   352  // DetachSender sends the Detach request. The method will close the
   353  // http.Response Body if it receives an error.
   354  func (client DisksClient) DetachSender(req *http.Request) (future DisksDetachFuture, err error) {
   355  	var resp *http.Response
   356  	future.FutureAPI = &azure.Future{}
   357  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   358  	if err != nil {
   359  		return
   360  	}
   361  	var azf azure.Future
   362  	azf, err = azure.NewFutureFromResponse(resp)
   363  	future.FutureAPI = &azf
   364  	future.Result = future.result
   365  	return
   366  }
   367  
   368  // DetachResponder handles the response to the Detach request. The method always
   369  // closes the http.Response Body.
   370  func (client DisksClient) DetachResponder(resp *http.Response) (result autorest.Response, err error) {
   371  	err = autorest.Respond(
   372  		resp,
   373  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   374  		autorest.ByClosing())
   375  	result.Response = resp
   376  	return
   377  }
   378  
   379  // Get get disk.
   380  // Parameters:
   381  // resourceGroupName - the name of the resource group.
   382  // labName - the name of the lab.
   383  // userName - the name of the user profile.
   384  // name - the name of the disk.
   385  // expand - specify the $expand query. Example: 'properties($select=diskType)'
   386  func (client DisksClient) Get(ctx context.Context, resourceGroupName string, labName string, userName string, name string, expand string) (result Disk, err error) {
   387  	if tracing.IsEnabled() {
   388  		ctx = tracing.StartSpan(ctx, fqdn+"/DisksClient.Get")
   389  		defer func() {
   390  			sc := -1
   391  			if result.Response.Response != nil {
   392  				sc = result.Response.Response.StatusCode
   393  			}
   394  			tracing.EndSpan(ctx, sc, err)
   395  		}()
   396  	}
   397  	req, err := client.GetPreparer(ctx, resourceGroupName, labName, userName, name, expand)
   398  	if err != nil {
   399  		err = autorest.NewErrorWithError(err, "dtl.DisksClient", "Get", nil, "Failure preparing request")
   400  		return
   401  	}
   402  
   403  	resp, err := client.GetSender(req)
   404  	if err != nil {
   405  		result.Response = autorest.Response{Response: resp}
   406  		err = autorest.NewErrorWithError(err, "dtl.DisksClient", "Get", resp, "Failure sending request")
   407  		return
   408  	}
   409  
   410  	result, err = client.GetResponder(resp)
   411  	if err != nil {
   412  		err = autorest.NewErrorWithError(err, "dtl.DisksClient", "Get", resp, "Failure responding to request")
   413  		return
   414  	}
   415  
   416  	return
   417  }
   418  
   419  // GetPreparer prepares the Get request.
   420  func (client DisksClient) GetPreparer(ctx context.Context, resourceGroupName string, labName string, userName string, name string, expand string) (*http.Request, error) {
   421  	pathParameters := map[string]interface{}{
   422  		"labName":           autorest.Encode("path", labName),
   423  		"name":              autorest.Encode("path", name),
   424  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   425  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   426  		"userName":          autorest.Encode("path", userName),
   427  	}
   428  
   429  	const APIVersion = "2016-05-15"
   430  	queryParameters := map[string]interface{}{
   431  		"api-version": APIVersion,
   432  	}
   433  	if len(expand) > 0 {
   434  		queryParameters["$expand"] = autorest.Encode("query", expand)
   435  	}
   436  
   437  	preparer := autorest.CreatePreparer(
   438  		autorest.AsGet(),
   439  		autorest.WithBaseURL(client.BaseURI),
   440  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks/{name}", pathParameters),
   441  		autorest.WithQueryParameters(queryParameters))
   442  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   443  }
   444  
   445  // GetSender sends the Get request. The method will close the
   446  // http.Response Body if it receives an error.
   447  func (client DisksClient) GetSender(req *http.Request) (*http.Response, error) {
   448  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   449  }
   450  
   451  // GetResponder handles the response to the Get request. The method always
   452  // closes the http.Response Body.
   453  func (client DisksClient) GetResponder(resp *http.Response) (result Disk, err error) {
   454  	err = autorest.Respond(
   455  		resp,
   456  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   457  		autorest.ByUnmarshallingJSON(&result),
   458  		autorest.ByClosing())
   459  	result.Response = autorest.Response{Response: resp}
   460  	return
   461  }
   462  
   463  // List list disks in a given user profile.
   464  // Parameters:
   465  // resourceGroupName - the name of the resource group.
   466  // labName - the name of the lab.
   467  // userName - the name of the user profile.
   468  // expand - specify the $expand query. Example: 'properties($select=diskType)'
   469  // filter - the filter to apply to the operation.
   470  // top - the maximum number of resources to return from the operation.
   471  // orderby - the ordering expression for the results, using OData notation.
   472  func (client DisksClient) List(ctx context.Context, resourceGroupName string, labName string, userName string, expand string, filter string, top *int32, orderby string) (result ResponseWithContinuationDiskPage, err error) {
   473  	if tracing.IsEnabled() {
   474  		ctx = tracing.StartSpan(ctx, fqdn+"/DisksClient.List")
   475  		defer func() {
   476  			sc := -1
   477  			if result.rwcd.Response.Response != nil {
   478  				sc = result.rwcd.Response.Response.StatusCode
   479  			}
   480  			tracing.EndSpan(ctx, sc, err)
   481  		}()
   482  	}
   483  	result.fn = client.listNextResults
   484  	req, err := client.ListPreparer(ctx, resourceGroupName, labName, userName, expand, filter, top, orderby)
   485  	if err != nil {
   486  		err = autorest.NewErrorWithError(err, "dtl.DisksClient", "List", nil, "Failure preparing request")
   487  		return
   488  	}
   489  
   490  	resp, err := client.ListSender(req)
   491  	if err != nil {
   492  		result.rwcd.Response = autorest.Response{Response: resp}
   493  		err = autorest.NewErrorWithError(err, "dtl.DisksClient", "List", resp, "Failure sending request")
   494  		return
   495  	}
   496  
   497  	result.rwcd, err = client.ListResponder(resp)
   498  	if err != nil {
   499  		err = autorest.NewErrorWithError(err, "dtl.DisksClient", "List", resp, "Failure responding to request")
   500  		return
   501  	}
   502  	if result.rwcd.hasNextLink() && result.rwcd.IsEmpty() {
   503  		err = result.NextWithContext(ctx)
   504  		return
   505  	}
   506  
   507  	return
   508  }
   509  
   510  // ListPreparer prepares the List request.
   511  func (client DisksClient) ListPreparer(ctx context.Context, resourceGroupName string, labName string, userName string, expand string, filter string, top *int32, orderby string) (*http.Request, error) {
   512  	pathParameters := map[string]interface{}{
   513  		"labName":           autorest.Encode("path", labName),
   514  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   515  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   516  		"userName":          autorest.Encode("path", userName),
   517  	}
   518  
   519  	const APIVersion = "2016-05-15"
   520  	queryParameters := map[string]interface{}{
   521  		"api-version": APIVersion,
   522  	}
   523  	if len(expand) > 0 {
   524  		queryParameters["$expand"] = autorest.Encode("query", expand)
   525  	}
   526  	if len(filter) > 0 {
   527  		queryParameters["$filter"] = autorest.Encode("query", filter)
   528  	}
   529  	if top != nil {
   530  		queryParameters["$top"] = autorest.Encode("query", *top)
   531  	}
   532  	if len(orderby) > 0 {
   533  		queryParameters["$orderby"] = autorest.Encode("query", orderby)
   534  	}
   535  
   536  	preparer := autorest.CreatePreparer(
   537  		autorest.AsGet(),
   538  		autorest.WithBaseURL(client.BaseURI),
   539  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks", pathParameters),
   540  		autorest.WithQueryParameters(queryParameters))
   541  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   542  }
   543  
   544  // ListSender sends the List request. The method will close the
   545  // http.Response Body if it receives an error.
   546  func (client DisksClient) ListSender(req *http.Request) (*http.Response, error) {
   547  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   548  }
   549  
   550  // ListResponder handles the response to the List request. The method always
   551  // closes the http.Response Body.
   552  func (client DisksClient) ListResponder(resp *http.Response) (result ResponseWithContinuationDisk, err error) {
   553  	err = autorest.Respond(
   554  		resp,
   555  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   556  		autorest.ByUnmarshallingJSON(&result),
   557  		autorest.ByClosing())
   558  	result.Response = autorest.Response{Response: resp}
   559  	return
   560  }
   561  
   562  // listNextResults retrieves the next set of results, if any.
   563  func (client DisksClient) listNextResults(ctx context.Context, lastResults ResponseWithContinuationDisk) (result ResponseWithContinuationDisk, err error) {
   564  	req, err := lastResults.responseWithContinuationDiskPreparer(ctx)
   565  	if err != nil {
   566  		return result, autorest.NewErrorWithError(err, "dtl.DisksClient", "listNextResults", nil, "Failure preparing next results request")
   567  	}
   568  	if req == nil {
   569  		return
   570  	}
   571  	resp, err := client.ListSender(req)
   572  	if err != nil {
   573  		result.Response = autorest.Response{Response: resp}
   574  		return result, autorest.NewErrorWithError(err, "dtl.DisksClient", "listNextResults", resp, "Failure sending next results request")
   575  	}
   576  	result, err = client.ListResponder(resp)
   577  	if err != nil {
   578  		err = autorest.NewErrorWithError(err, "dtl.DisksClient", "listNextResults", resp, "Failure responding to next results request")
   579  	}
   580  	return
   581  }
   582  
   583  // ListComplete enumerates all values, automatically crossing page boundaries as required.
   584  func (client DisksClient) ListComplete(ctx context.Context, resourceGroupName string, labName string, userName string, expand string, filter string, top *int32, orderby string) (result ResponseWithContinuationDiskIterator, err error) {
   585  	if tracing.IsEnabled() {
   586  		ctx = tracing.StartSpan(ctx, fqdn+"/DisksClient.List")
   587  		defer func() {
   588  			sc := -1
   589  			if result.Response().Response.Response != nil {
   590  				sc = result.page.Response().Response.Response.StatusCode
   591  			}
   592  			tracing.EndSpan(ctx, sc, err)
   593  		}()
   594  	}
   595  	result.page, err = client.List(ctx, resourceGroupName, labName, userName, expand, filter, top, orderby)
   596  	return
   597  }
   598  

View as plain text