...

Source file src/github.com/Azure/azure-sdk-for-go/services/storsimple8000series/mgmt/2017-06-01/storsimple/devices.go

Documentation: github.com/Azure/azure-sdk-for-go/services/storsimple8000series/mgmt/2017-06-01/storsimple

     1  package storsimple
     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  // DevicesClient is the client for the Devices methods of the Storsimple service.
    19  type DevicesClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewDevicesClient creates an instance of the DevicesClient client.
    24  func NewDevicesClient(subscriptionID string) DevicesClient {
    25  	return NewDevicesClientWithBaseURI(DefaultBaseURI, subscriptionID)
    26  }
    27  
    28  // NewDevicesClientWithBaseURI creates an instance of the DevicesClient 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 NewDevicesClientWithBaseURI(baseURI string, subscriptionID string) DevicesClient {
    31  	return DevicesClient{NewWithBaseURI(baseURI, subscriptionID)}
    32  }
    33  
    34  // AuthorizeForServiceEncryptionKeyRollover authorizes the specified device for service data encryption key rollover.
    35  // Parameters:
    36  // deviceName - the device name
    37  // resourceGroupName - the resource group name
    38  // managerName - the manager name
    39  func (client DevicesClient) AuthorizeForServiceEncryptionKeyRollover(ctx context.Context, deviceName string, resourceGroupName string, managerName string) (result autorest.Response, err error) {
    40  	if tracing.IsEnabled() {
    41  		ctx = tracing.StartSpan(ctx, fqdn+"/DevicesClient.AuthorizeForServiceEncryptionKeyRollover")
    42  		defer func() {
    43  			sc := -1
    44  			if result.Response != nil {
    45  				sc = result.Response.StatusCode
    46  			}
    47  			tracing.EndSpan(ctx, sc, err)
    48  		}()
    49  	}
    50  	if err := validation.Validate([]validation.Validation{
    51  		{TargetValue: managerName,
    52  			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
    53  				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
    54  		return result, validation.NewError("storsimple.DevicesClient", "AuthorizeForServiceEncryptionKeyRollover", err.Error())
    55  	}
    56  
    57  	req, err := client.AuthorizeForServiceEncryptionKeyRolloverPreparer(ctx, deviceName, resourceGroupName, managerName)
    58  	if err != nil {
    59  		err = autorest.NewErrorWithError(err, "storsimple.DevicesClient", "AuthorizeForServiceEncryptionKeyRollover", nil, "Failure preparing request")
    60  		return
    61  	}
    62  
    63  	resp, err := client.AuthorizeForServiceEncryptionKeyRolloverSender(req)
    64  	if err != nil {
    65  		result.Response = resp
    66  		err = autorest.NewErrorWithError(err, "storsimple.DevicesClient", "AuthorizeForServiceEncryptionKeyRollover", resp, "Failure sending request")
    67  		return
    68  	}
    69  
    70  	result, err = client.AuthorizeForServiceEncryptionKeyRolloverResponder(resp)
    71  	if err != nil {
    72  		err = autorest.NewErrorWithError(err, "storsimple.DevicesClient", "AuthorizeForServiceEncryptionKeyRollover", resp, "Failure responding to request")
    73  		return
    74  	}
    75  
    76  	return
    77  }
    78  
    79  // AuthorizeForServiceEncryptionKeyRolloverPreparer prepares the AuthorizeForServiceEncryptionKeyRollover request.
    80  func (client DevicesClient) AuthorizeForServiceEncryptionKeyRolloverPreparer(ctx context.Context, deviceName string, resourceGroupName string, managerName string) (*http.Request, error) {
    81  	pathParameters := map[string]interface{}{
    82  		"deviceName":        deviceName,
    83  		"managerName":       managerName,
    84  		"resourceGroupName": resourceGroupName,
    85  		"subscriptionId":    client.SubscriptionID,
    86  	}
    87  
    88  	const APIVersion = "2017-06-01"
    89  	queryParameters := map[string]interface{}{
    90  		"api-version": APIVersion,
    91  	}
    92  
    93  	preparer := autorest.CreatePreparer(
    94  		autorest.AsPost(),
    95  		autorest.WithBaseURL(client.BaseURI),
    96  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/authorizeForServiceEncryptionKeyRollover", pathParameters),
    97  		autorest.WithQueryParameters(queryParameters))
    98  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    99  }
   100  
   101  // AuthorizeForServiceEncryptionKeyRolloverSender sends the AuthorizeForServiceEncryptionKeyRollover request. The method will close the
   102  // http.Response Body if it receives an error.
   103  func (client DevicesClient) AuthorizeForServiceEncryptionKeyRolloverSender(req *http.Request) (*http.Response, error) {
   104  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   105  }
   106  
   107  // AuthorizeForServiceEncryptionKeyRolloverResponder handles the response to the AuthorizeForServiceEncryptionKeyRollover request. The method always
   108  // closes the http.Response Body.
   109  func (client DevicesClient) AuthorizeForServiceEncryptionKeyRolloverResponder(resp *http.Response) (result autorest.Response, err error) {
   110  	err = autorest.Respond(
   111  		resp,
   112  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
   113  		autorest.ByClosing())
   114  	result.Response = resp
   115  	return
   116  }
   117  
   118  // Configure complete minimal setup before using the device.
   119  // Parameters:
   120  // parameters - the minimal properties to configure a device.
   121  // resourceGroupName - the resource group name
   122  // managerName - the manager name
   123  func (client DevicesClient) Configure(ctx context.Context, parameters ConfigureDeviceRequest, resourceGroupName string, managerName string) (result DevicesConfigureFuture, err error) {
   124  	if tracing.IsEnabled() {
   125  		ctx = tracing.StartSpan(ctx, fqdn+"/DevicesClient.Configure")
   126  		defer func() {
   127  			sc := -1
   128  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   129  				sc = result.FutureAPI.Response().StatusCode
   130  			}
   131  			tracing.EndSpan(ctx, sc, err)
   132  		}()
   133  	}
   134  	if err := validation.Validate([]validation.Validation{
   135  		{TargetValue: parameters,
   136  			Constraints: []validation.Constraint{{Target: "parameters.ConfigureDeviceRequestProperties", Name: validation.Null, Rule: true,
   137  				Chain: []validation.Constraint{{Target: "parameters.ConfigureDeviceRequestProperties.FriendlyName", Name: validation.Null, Rule: true, Chain: nil},
   138  					{Target: "parameters.ConfigureDeviceRequestProperties.CurrentDeviceName", Name: validation.Null, Rule: true, Chain: nil},
   139  					{Target: "parameters.ConfigureDeviceRequestProperties.TimeZone", Name: validation.Null, Rule: true, Chain: nil},
   140  				}}}},
   141  		{TargetValue: managerName,
   142  			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   143  				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
   144  		return result, validation.NewError("storsimple.DevicesClient", "Configure", err.Error())
   145  	}
   146  
   147  	req, err := client.ConfigurePreparer(ctx, parameters, resourceGroupName, managerName)
   148  	if err != nil {
   149  		err = autorest.NewErrorWithError(err, "storsimple.DevicesClient", "Configure", nil, "Failure preparing request")
   150  		return
   151  	}
   152  
   153  	result, err = client.ConfigureSender(req)
   154  	if err != nil {
   155  		err = autorest.NewErrorWithError(err, "storsimple.DevicesClient", "Configure", result.Response(), "Failure sending request")
   156  		return
   157  	}
   158  
   159  	return
   160  }
   161  
   162  // ConfigurePreparer prepares the Configure request.
   163  func (client DevicesClient) ConfigurePreparer(ctx context.Context, parameters ConfigureDeviceRequest, resourceGroupName string, managerName string) (*http.Request, error) {
   164  	pathParameters := map[string]interface{}{
   165  		"managerName":       managerName,
   166  		"resourceGroupName": resourceGroupName,
   167  		"subscriptionId":    client.SubscriptionID,
   168  	}
   169  
   170  	const APIVersion = "2017-06-01"
   171  	queryParameters := map[string]interface{}{
   172  		"api-version": APIVersion,
   173  	}
   174  
   175  	preparer := autorest.CreatePreparer(
   176  		autorest.AsContentType("application/json; charset=utf-8"),
   177  		autorest.AsPost(),
   178  		autorest.WithBaseURL(client.BaseURI),
   179  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/configureDevice", pathParameters),
   180  		autorest.WithJSON(parameters),
   181  		autorest.WithQueryParameters(queryParameters))
   182  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   183  }
   184  
   185  // ConfigureSender sends the Configure request. The method will close the
   186  // http.Response Body if it receives an error.
   187  func (client DevicesClient) ConfigureSender(req *http.Request) (future DevicesConfigureFuture, err error) {
   188  	var resp *http.Response
   189  	future.FutureAPI = &azure.Future{}
   190  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   191  	if err != nil {
   192  		return
   193  	}
   194  	var azf azure.Future
   195  	azf, err = azure.NewFutureFromResponse(resp)
   196  	future.FutureAPI = &azf
   197  	future.Result = future.result
   198  	return
   199  }
   200  
   201  // ConfigureResponder handles the response to the Configure request. The method always
   202  // closes the http.Response Body.
   203  func (client DevicesClient) ConfigureResponder(resp *http.Response) (result autorest.Response, err error) {
   204  	err = autorest.Respond(
   205  		resp,
   206  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   207  		autorest.ByClosing())
   208  	result.Response = resp
   209  	return
   210  }
   211  
   212  // Deactivate deactivates the device.
   213  // Parameters:
   214  // deviceName - the device name
   215  // resourceGroupName - the resource group name
   216  // managerName - the manager name
   217  func (client DevicesClient) Deactivate(ctx context.Context, deviceName string, resourceGroupName string, managerName string) (result DevicesDeactivateFuture, err error) {
   218  	if tracing.IsEnabled() {
   219  		ctx = tracing.StartSpan(ctx, fqdn+"/DevicesClient.Deactivate")
   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  	if err := validation.Validate([]validation.Validation{
   229  		{TargetValue: managerName,
   230  			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   231  				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
   232  		return result, validation.NewError("storsimple.DevicesClient", "Deactivate", err.Error())
   233  	}
   234  
   235  	req, err := client.DeactivatePreparer(ctx, deviceName, resourceGroupName, managerName)
   236  	if err != nil {
   237  		err = autorest.NewErrorWithError(err, "storsimple.DevicesClient", "Deactivate", nil, "Failure preparing request")
   238  		return
   239  	}
   240  
   241  	result, err = client.DeactivateSender(req)
   242  	if err != nil {
   243  		err = autorest.NewErrorWithError(err, "storsimple.DevicesClient", "Deactivate", result.Response(), "Failure sending request")
   244  		return
   245  	}
   246  
   247  	return
   248  }
   249  
   250  // DeactivatePreparer prepares the Deactivate request.
   251  func (client DevicesClient) DeactivatePreparer(ctx context.Context, deviceName string, resourceGroupName string, managerName string) (*http.Request, error) {
   252  	pathParameters := map[string]interface{}{
   253  		"deviceName":        deviceName,
   254  		"managerName":       managerName,
   255  		"resourceGroupName": resourceGroupName,
   256  		"subscriptionId":    client.SubscriptionID,
   257  	}
   258  
   259  	const APIVersion = "2017-06-01"
   260  	queryParameters := map[string]interface{}{
   261  		"api-version": APIVersion,
   262  	}
   263  
   264  	preparer := autorest.CreatePreparer(
   265  		autorest.AsPost(),
   266  		autorest.WithBaseURL(client.BaseURI),
   267  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/deactivate", pathParameters),
   268  		autorest.WithQueryParameters(queryParameters))
   269  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   270  }
   271  
   272  // DeactivateSender sends the Deactivate request. The method will close the
   273  // http.Response Body if it receives an error.
   274  func (client DevicesClient) DeactivateSender(req *http.Request) (future DevicesDeactivateFuture, err error) {
   275  	var resp *http.Response
   276  	future.FutureAPI = &azure.Future{}
   277  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   278  	if err != nil {
   279  		return
   280  	}
   281  	var azf azure.Future
   282  	azf, err = azure.NewFutureFromResponse(resp)
   283  	future.FutureAPI = &azf
   284  	future.Result = future.result
   285  	return
   286  }
   287  
   288  // DeactivateResponder handles the response to the Deactivate request. The method always
   289  // closes the http.Response Body.
   290  func (client DevicesClient) DeactivateResponder(resp *http.Response) (result autorest.Response, err error) {
   291  	err = autorest.Respond(
   292  		resp,
   293  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   294  		autorest.ByClosing())
   295  	result.Response = resp
   296  	return
   297  }
   298  
   299  // Delete deletes the device.
   300  // Parameters:
   301  // deviceName - the device name
   302  // resourceGroupName - the resource group name
   303  // managerName - the manager name
   304  func (client DevicesClient) Delete(ctx context.Context, deviceName string, resourceGroupName string, managerName string) (result DevicesDeleteFuture, err error) {
   305  	if tracing.IsEnabled() {
   306  		ctx = tracing.StartSpan(ctx, fqdn+"/DevicesClient.Delete")
   307  		defer func() {
   308  			sc := -1
   309  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   310  				sc = result.FutureAPI.Response().StatusCode
   311  			}
   312  			tracing.EndSpan(ctx, sc, err)
   313  		}()
   314  	}
   315  	if err := validation.Validate([]validation.Validation{
   316  		{TargetValue: managerName,
   317  			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   318  				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
   319  		return result, validation.NewError("storsimple.DevicesClient", "Delete", err.Error())
   320  	}
   321  
   322  	req, err := client.DeletePreparer(ctx, deviceName, resourceGroupName, managerName)
   323  	if err != nil {
   324  		err = autorest.NewErrorWithError(err, "storsimple.DevicesClient", "Delete", nil, "Failure preparing request")
   325  		return
   326  	}
   327  
   328  	result, err = client.DeleteSender(req)
   329  	if err != nil {
   330  		err = autorest.NewErrorWithError(err, "storsimple.DevicesClient", "Delete", result.Response(), "Failure sending request")
   331  		return
   332  	}
   333  
   334  	return
   335  }
   336  
   337  // DeletePreparer prepares the Delete request.
   338  func (client DevicesClient) DeletePreparer(ctx context.Context, deviceName string, resourceGroupName string, managerName string) (*http.Request, error) {
   339  	pathParameters := map[string]interface{}{
   340  		"deviceName":        deviceName,
   341  		"managerName":       managerName,
   342  		"resourceGroupName": resourceGroupName,
   343  		"subscriptionId":    client.SubscriptionID,
   344  	}
   345  
   346  	const APIVersion = "2017-06-01"
   347  	queryParameters := map[string]interface{}{
   348  		"api-version": APIVersion,
   349  	}
   350  
   351  	preparer := autorest.CreatePreparer(
   352  		autorest.AsDelete(),
   353  		autorest.WithBaseURL(client.BaseURI),
   354  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}", pathParameters),
   355  		autorest.WithQueryParameters(queryParameters))
   356  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   357  }
   358  
   359  // DeleteSender sends the Delete request. The method will close the
   360  // http.Response Body if it receives an error.
   361  func (client DevicesClient) DeleteSender(req *http.Request) (future DevicesDeleteFuture, err error) {
   362  	var resp *http.Response
   363  	future.FutureAPI = &azure.Future{}
   364  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   365  	if err != nil {
   366  		return
   367  	}
   368  	var azf azure.Future
   369  	azf, err = azure.NewFutureFromResponse(resp)
   370  	future.FutureAPI = &azf
   371  	future.Result = future.result
   372  	return
   373  }
   374  
   375  // DeleteResponder handles the response to the Delete request. The method always
   376  // closes the http.Response Body.
   377  func (client DevicesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
   378  	err = autorest.Respond(
   379  		resp,
   380  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   381  		autorest.ByClosing())
   382  	result.Response = resp
   383  	return
   384  }
   385  
   386  // Failover failovers a set of volume containers from a specified source device to a target device.
   387  // Parameters:
   388  // sourceDeviceName - the source device name on which failover is performed.
   389  // parameters - failoverRequest containing the source device and the list of volume containers to be failed
   390  // over.
   391  // resourceGroupName - the resource group name
   392  // managerName - the manager name
   393  func (client DevicesClient) Failover(ctx context.Context, sourceDeviceName string, parameters FailoverRequest, resourceGroupName string, managerName string) (result DevicesFailoverFuture, err error) {
   394  	if tracing.IsEnabled() {
   395  		ctx = tracing.StartSpan(ctx, fqdn+"/DevicesClient.Failover")
   396  		defer func() {
   397  			sc := -1
   398  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   399  				sc = result.FutureAPI.Response().StatusCode
   400  			}
   401  			tracing.EndSpan(ctx, sc, err)
   402  		}()
   403  	}
   404  	if err := validation.Validate([]validation.Validation{
   405  		{TargetValue: managerName,
   406  			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   407  				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
   408  		return result, validation.NewError("storsimple.DevicesClient", "Failover", err.Error())
   409  	}
   410  
   411  	req, err := client.FailoverPreparer(ctx, sourceDeviceName, parameters, resourceGroupName, managerName)
   412  	if err != nil {
   413  		err = autorest.NewErrorWithError(err, "storsimple.DevicesClient", "Failover", nil, "Failure preparing request")
   414  		return
   415  	}
   416  
   417  	result, err = client.FailoverSender(req)
   418  	if err != nil {
   419  		err = autorest.NewErrorWithError(err, "storsimple.DevicesClient", "Failover", result.Response(), "Failure sending request")
   420  		return
   421  	}
   422  
   423  	return
   424  }
   425  
   426  // FailoverPreparer prepares the Failover request.
   427  func (client DevicesClient) FailoverPreparer(ctx context.Context, sourceDeviceName string, parameters FailoverRequest, resourceGroupName string, managerName string) (*http.Request, error) {
   428  	pathParameters := map[string]interface{}{
   429  		"managerName":       managerName,
   430  		"resourceGroupName": resourceGroupName,
   431  		"sourceDeviceName":  sourceDeviceName,
   432  		"subscriptionId":    client.SubscriptionID,
   433  	}
   434  
   435  	const APIVersion = "2017-06-01"
   436  	queryParameters := map[string]interface{}{
   437  		"api-version": APIVersion,
   438  	}
   439  
   440  	preparer := autorest.CreatePreparer(
   441  		autorest.AsContentType("application/json; charset=utf-8"),
   442  		autorest.AsPost(),
   443  		autorest.WithBaseURL(client.BaseURI),
   444  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{sourceDeviceName}/failover", pathParameters),
   445  		autorest.WithJSON(parameters),
   446  		autorest.WithQueryParameters(queryParameters))
   447  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   448  }
   449  
   450  // FailoverSender sends the Failover request. The method will close the
   451  // http.Response Body if it receives an error.
   452  func (client DevicesClient) FailoverSender(req *http.Request) (future DevicesFailoverFuture, err error) {
   453  	var resp *http.Response
   454  	future.FutureAPI = &azure.Future{}
   455  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   456  	if err != nil {
   457  		return
   458  	}
   459  	var azf azure.Future
   460  	azf, err = azure.NewFutureFromResponse(resp)
   461  	future.FutureAPI = &azf
   462  	future.Result = future.result
   463  	return
   464  }
   465  
   466  // FailoverResponder handles the response to the Failover request. The method always
   467  // closes the http.Response Body.
   468  func (client DevicesClient) FailoverResponder(resp *http.Response) (result autorest.Response, err error) {
   469  	err = autorest.Respond(
   470  		resp,
   471  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   472  		autorest.ByClosing())
   473  	result.Response = resp
   474  	return
   475  }
   476  
   477  // Get returns the properties of the specified device.
   478  // Parameters:
   479  // deviceName - the device name
   480  // resourceGroupName - the resource group name
   481  // managerName - the manager name
   482  // expand - specify $expand=details to populate additional fields related to the device or
   483  // $expand=rolloverdetails to populate additional fields related to the service data encryption key rollover on
   484  // device
   485  func (client DevicesClient) Get(ctx context.Context, deviceName string, resourceGroupName string, managerName string, expand string) (result Device, err error) {
   486  	if tracing.IsEnabled() {
   487  		ctx = tracing.StartSpan(ctx, fqdn+"/DevicesClient.Get")
   488  		defer func() {
   489  			sc := -1
   490  			if result.Response.Response != nil {
   491  				sc = result.Response.Response.StatusCode
   492  			}
   493  			tracing.EndSpan(ctx, sc, err)
   494  		}()
   495  	}
   496  	if err := validation.Validate([]validation.Validation{
   497  		{TargetValue: managerName,
   498  			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   499  				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
   500  		return result, validation.NewError("storsimple.DevicesClient", "Get", err.Error())
   501  	}
   502  
   503  	req, err := client.GetPreparer(ctx, deviceName, resourceGroupName, managerName, expand)
   504  	if err != nil {
   505  		err = autorest.NewErrorWithError(err, "storsimple.DevicesClient", "Get", nil, "Failure preparing request")
   506  		return
   507  	}
   508  
   509  	resp, err := client.GetSender(req)
   510  	if err != nil {
   511  		result.Response = autorest.Response{Response: resp}
   512  		err = autorest.NewErrorWithError(err, "storsimple.DevicesClient", "Get", resp, "Failure sending request")
   513  		return
   514  	}
   515  
   516  	result, err = client.GetResponder(resp)
   517  	if err != nil {
   518  		err = autorest.NewErrorWithError(err, "storsimple.DevicesClient", "Get", resp, "Failure responding to request")
   519  		return
   520  	}
   521  
   522  	return
   523  }
   524  
   525  // GetPreparer prepares the Get request.
   526  func (client DevicesClient) GetPreparer(ctx context.Context, deviceName string, resourceGroupName string, managerName string, expand string) (*http.Request, error) {
   527  	pathParameters := map[string]interface{}{
   528  		"deviceName":        deviceName,
   529  		"managerName":       managerName,
   530  		"resourceGroupName": resourceGroupName,
   531  		"subscriptionId":    client.SubscriptionID,
   532  	}
   533  
   534  	const APIVersion = "2017-06-01"
   535  	queryParameters := map[string]interface{}{
   536  		"api-version": APIVersion,
   537  	}
   538  	if len(expand) > 0 {
   539  		queryParameters["$expand"] = autorest.Encode("query", expand)
   540  	}
   541  
   542  	preparer := autorest.CreatePreparer(
   543  		autorest.AsGet(),
   544  		autorest.WithBaseURL(client.BaseURI),
   545  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}", pathParameters),
   546  		autorest.WithQueryParameters(queryParameters))
   547  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   548  }
   549  
   550  // GetSender sends the Get request. The method will close the
   551  // http.Response Body if it receives an error.
   552  func (client DevicesClient) GetSender(req *http.Request) (*http.Response, error) {
   553  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   554  }
   555  
   556  // GetResponder handles the response to the Get request. The method always
   557  // closes the http.Response Body.
   558  func (client DevicesClient) GetResponder(resp *http.Response) (result Device, err error) {
   559  	err = autorest.Respond(
   560  		resp,
   561  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   562  		autorest.ByUnmarshallingJSON(&result),
   563  		autorest.ByClosing())
   564  	result.Response = autorest.Response{Response: resp}
   565  	return
   566  }
   567  
   568  // GetUpdateSummary returns the update summary of the specified device name.
   569  // Parameters:
   570  // deviceName - the device name
   571  // resourceGroupName - the resource group name
   572  // managerName - the manager name
   573  func (client DevicesClient) GetUpdateSummary(ctx context.Context, deviceName string, resourceGroupName string, managerName string) (result Updates, err error) {
   574  	if tracing.IsEnabled() {
   575  		ctx = tracing.StartSpan(ctx, fqdn+"/DevicesClient.GetUpdateSummary")
   576  		defer func() {
   577  			sc := -1
   578  			if result.Response.Response != nil {
   579  				sc = result.Response.Response.StatusCode
   580  			}
   581  			tracing.EndSpan(ctx, sc, err)
   582  		}()
   583  	}
   584  	if err := validation.Validate([]validation.Validation{
   585  		{TargetValue: managerName,
   586  			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   587  				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
   588  		return result, validation.NewError("storsimple.DevicesClient", "GetUpdateSummary", err.Error())
   589  	}
   590  
   591  	req, err := client.GetUpdateSummaryPreparer(ctx, deviceName, resourceGroupName, managerName)
   592  	if err != nil {
   593  		err = autorest.NewErrorWithError(err, "storsimple.DevicesClient", "GetUpdateSummary", nil, "Failure preparing request")
   594  		return
   595  	}
   596  
   597  	resp, err := client.GetUpdateSummarySender(req)
   598  	if err != nil {
   599  		result.Response = autorest.Response{Response: resp}
   600  		err = autorest.NewErrorWithError(err, "storsimple.DevicesClient", "GetUpdateSummary", resp, "Failure sending request")
   601  		return
   602  	}
   603  
   604  	result, err = client.GetUpdateSummaryResponder(resp)
   605  	if err != nil {
   606  		err = autorest.NewErrorWithError(err, "storsimple.DevicesClient", "GetUpdateSummary", resp, "Failure responding to request")
   607  		return
   608  	}
   609  
   610  	return
   611  }
   612  
   613  // GetUpdateSummaryPreparer prepares the GetUpdateSummary request.
   614  func (client DevicesClient) GetUpdateSummaryPreparer(ctx context.Context, deviceName string, resourceGroupName string, managerName string) (*http.Request, error) {
   615  	pathParameters := map[string]interface{}{
   616  		"deviceName":        deviceName,
   617  		"managerName":       managerName,
   618  		"resourceGroupName": resourceGroupName,
   619  		"subscriptionId":    client.SubscriptionID,
   620  	}
   621  
   622  	const APIVersion = "2017-06-01"
   623  	queryParameters := map[string]interface{}{
   624  		"api-version": APIVersion,
   625  	}
   626  
   627  	preparer := autorest.CreatePreparer(
   628  		autorest.AsGet(),
   629  		autorest.WithBaseURL(client.BaseURI),
   630  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/updateSummary/default", pathParameters),
   631  		autorest.WithQueryParameters(queryParameters))
   632  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   633  }
   634  
   635  // GetUpdateSummarySender sends the GetUpdateSummary request. The method will close the
   636  // http.Response Body if it receives an error.
   637  func (client DevicesClient) GetUpdateSummarySender(req *http.Request) (*http.Response, error) {
   638  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   639  }
   640  
   641  // GetUpdateSummaryResponder handles the response to the GetUpdateSummary request. The method always
   642  // closes the http.Response Body.
   643  func (client DevicesClient) GetUpdateSummaryResponder(resp *http.Response) (result Updates, err error) {
   644  	err = autorest.Respond(
   645  		resp,
   646  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   647  		autorest.ByUnmarshallingJSON(&result),
   648  		autorest.ByClosing())
   649  	result.Response = autorest.Response{Response: resp}
   650  	return
   651  }
   652  
   653  // InstallUpdates downloads and installs the updates on the device.
   654  // Parameters:
   655  // deviceName - the device name
   656  // resourceGroupName - the resource group name
   657  // managerName - the manager name
   658  func (client DevicesClient) InstallUpdates(ctx context.Context, deviceName string, resourceGroupName string, managerName string) (result DevicesInstallUpdatesFuture, err error) {
   659  	if tracing.IsEnabled() {
   660  		ctx = tracing.StartSpan(ctx, fqdn+"/DevicesClient.InstallUpdates")
   661  		defer func() {
   662  			sc := -1
   663  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   664  				sc = result.FutureAPI.Response().StatusCode
   665  			}
   666  			tracing.EndSpan(ctx, sc, err)
   667  		}()
   668  	}
   669  	if err := validation.Validate([]validation.Validation{
   670  		{TargetValue: managerName,
   671  			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   672  				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
   673  		return result, validation.NewError("storsimple.DevicesClient", "InstallUpdates", err.Error())
   674  	}
   675  
   676  	req, err := client.InstallUpdatesPreparer(ctx, deviceName, resourceGroupName, managerName)
   677  	if err != nil {
   678  		err = autorest.NewErrorWithError(err, "storsimple.DevicesClient", "InstallUpdates", nil, "Failure preparing request")
   679  		return
   680  	}
   681  
   682  	result, err = client.InstallUpdatesSender(req)
   683  	if err != nil {
   684  		err = autorest.NewErrorWithError(err, "storsimple.DevicesClient", "InstallUpdates", result.Response(), "Failure sending request")
   685  		return
   686  	}
   687  
   688  	return
   689  }
   690  
   691  // InstallUpdatesPreparer prepares the InstallUpdates request.
   692  func (client DevicesClient) InstallUpdatesPreparer(ctx context.Context, deviceName string, resourceGroupName string, managerName string) (*http.Request, error) {
   693  	pathParameters := map[string]interface{}{
   694  		"deviceName":        deviceName,
   695  		"managerName":       managerName,
   696  		"resourceGroupName": resourceGroupName,
   697  		"subscriptionId":    client.SubscriptionID,
   698  	}
   699  
   700  	const APIVersion = "2017-06-01"
   701  	queryParameters := map[string]interface{}{
   702  		"api-version": APIVersion,
   703  	}
   704  
   705  	preparer := autorest.CreatePreparer(
   706  		autorest.AsPost(),
   707  		autorest.WithBaseURL(client.BaseURI),
   708  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/installUpdates", pathParameters),
   709  		autorest.WithQueryParameters(queryParameters))
   710  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   711  }
   712  
   713  // InstallUpdatesSender sends the InstallUpdates request. The method will close the
   714  // http.Response Body if it receives an error.
   715  func (client DevicesClient) InstallUpdatesSender(req *http.Request) (future DevicesInstallUpdatesFuture, err error) {
   716  	var resp *http.Response
   717  	future.FutureAPI = &azure.Future{}
   718  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   719  	if err != nil {
   720  		return
   721  	}
   722  	var azf azure.Future
   723  	azf, err = azure.NewFutureFromResponse(resp)
   724  	future.FutureAPI = &azf
   725  	future.Result = future.result
   726  	return
   727  }
   728  
   729  // InstallUpdatesResponder handles the response to the InstallUpdates request. The method always
   730  // closes the http.Response Body.
   731  func (client DevicesClient) InstallUpdatesResponder(resp *http.Response) (result autorest.Response, err error) {
   732  	err = autorest.Respond(
   733  		resp,
   734  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   735  		autorest.ByClosing())
   736  	result.Response = resp
   737  	return
   738  }
   739  
   740  // ListByManager returns the list of devices for the specified manager.
   741  // Parameters:
   742  // resourceGroupName - the resource group name
   743  // managerName - the manager name
   744  // expand - specify $expand=details to populate additional fields related to the device or
   745  // $expand=rolloverdetails to populate additional fields related to the service data encryption key rollover on
   746  // device
   747  func (client DevicesClient) ListByManager(ctx context.Context, resourceGroupName string, managerName string, expand string) (result DeviceList, err error) {
   748  	if tracing.IsEnabled() {
   749  		ctx = tracing.StartSpan(ctx, fqdn+"/DevicesClient.ListByManager")
   750  		defer func() {
   751  			sc := -1
   752  			if result.Response.Response != nil {
   753  				sc = result.Response.Response.StatusCode
   754  			}
   755  			tracing.EndSpan(ctx, sc, err)
   756  		}()
   757  	}
   758  	if err := validation.Validate([]validation.Validation{
   759  		{TargetValue: managerName,
   760  			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   761  				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
   762  		return result, validation.NewError("storsimple.DevicesClient", "ListByManager", err.Error())
   763  	}
   764  
   765  	req, err := client.ListByManagerPreparer(ctx, resourceGroupName, managerName, expand)
   766  	if err != nil {
   767  		err = autorest.NewErrorWithError(err, "storsimple.DevicesClient", "ListByManager", nil, "Failure preparing request")
   768  		return
   769  	}
   770  
   771  	resp, err := client.ListByManagerSender(req)
   772  	if err != nil {
   773  		result.Response = autorest.Response{Response: resp}
   774  		err = autorest.NewErrorWithError(err, "storsimple.DevicesClient", "ListByManager", resp, "Failure sending request")
   775  		return
   776  	}
   777  
   778  	result, err = client.ListByManagerResponder(resp)
   779  	if err != nil {
   780  		err = autorest.NewErrorWithError(err, "storsimple.DevicesClient", "ListByManager", resp, "Failure responding to request")
   781  		return
   782  	}
   783  
   784  	return
   785  }
   786  
   787  // ListByManagerPreparer prepares the ListByManager request.
   788  func (client DevicesClient) ListByManagerPreparer(ctx context.Context, resourceGroupName string, managerName string, expand string) (*http.Request, error) {
   789  	pathParameters := map[string]interface{}{
   790  		"managerName":       managerName,
   791  		"resourceGroupName": resourceGroupName,
   792  		"subscriptionId":    client.SubscriptionID,
   793  	}
   794  
   795  	const APIVersion = "2017-06-01"
   796  	queryParameters := map[string]interface{}{
   797  		"api-version": APIVersion,
   798  	}
   799  	if len(expand) > 0 {
   800  		queryParameters["$expand"] = autorest.Encode("query", expand)
   801  	}
   802  
   803  	preparer := autorest.CreatePreparer(
   804  		autorest.AsGet(),
   805  		autorest.WithBaseURL(client.BaseURI),
   806  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices", pathParameters),
   807  		autorest.WithQueryParameters(queryParameters))
   808  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   809  }
   810  
   811  // ListByManagerSender sends the ListByManager request. The method will close the
   812  // http.Response Body if it receives an error.
   813  func (client DevicesClient) ListByManagerSender(req *http.Request) (*http.Response, error) {
   814  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   815  }
   816  
   817  // ListByManagerResponder handles the response to the ListByManager request. The method always
   818  // closes the http.Response Body.
   819  func (client DevicesClient) ListByManagerResponder(resp *http.Response) (result DeviceList, err error) {
   820  	err = autorest.Respond(
   821  		resp,
   822  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   823  		autorest.ByUnmarshallingJSON(&result),
   824  		autorest.ByClosing())
   825  	result.Response = autorest.Response{Response: resp}
   826  	return
   827  }
   828  
   829  // ListFailoverSets returns all failover sets for a given device and their eligibility for participating in a failover.
   830  // A failover set refers to a set of volume containers that need to be failed-over as a single unit to maintain data
   831  // integrity.
   832  // Parameters:
   833  // deviceName - the device name
   834  // resourceGroupName - the resource group name
   835  // managerName - the manager name
   836  func (client DevicesClient) ListFailoverSets(ctx context.Context, deviceName string, resourceGroupName string, managerName string) (result FailoverSetsList, err error) {
   837  	if tracing.IsEnabled() {
   838  		ctx = tracing.StartSpan(ctx, fqdn+"/DevicesClient.ListFailoverSets")
   839  		defer func() {
   840  			sc := -1
   841  			if result.Response.Response != nil {
   842  				sc = result.Response.Response.StatusCode
   843  			}
   844  			tracing.EndSpan(ctx, sc, err)
   845  		}()
   846  	}
   847  	if err := validation.Validate([]validation.Validation{
   848  		{TargetValue: managerName,
   849  			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   850  				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
   851  		return result, validation.NewError("storsimple.DevicesClient", "ListFailoverSets", err.Error())
   852  	}
   853  
   854  	req, err := client.ListFailoverSetsPreparer(ctx, deviceName, resourceGroupName, managerName)
   855  	if err != nil {
   856  		err = autorest.NewErrorWithError(err, "storsimple.DevicesClient", "ListFailoverSets", nil, "Failure preparing request")
   857  		return
   858  	}
   859  
   860  	resp, err := client.ListFailoverSetsSender(req)
   861  	if err != nil {
   862  		result.Response = autorest.Response{Response: resp}
   863  		err = autorest.NewErrorWithError(err, "storsimple.DevicesClient", "ListFailoverSets", resp, "Failure sending request")
   864  		return
   865  	}
   866  
   867  	result, err = client.ListFailoverSetsResponder(resp)
   868  	if err != nil {
   869  		err = autorest.NewErrorWithError(err, "storsimple.DevicesClient", "ListFailoverSets", resp, "Failure responding to request")
   870  		return
   871  	}
   872  
   873  	return
   874  }
   875  
   876  // ListFailoverSetsPreparer prepares the ListFailoverSets request.
   877  func (client DevicesClient) ListFailoverSetsPreparer(ctx context.Context, deviceName string, resourceGroupName string, managerName string) (*http.Request, error) {
   878  	pathParameters := map[string]interface{}{
   879  		"deviceName":        deviceName,
   880  		"managerName":       managerName,
   881  		"resourceGroupName": resourceGroupName,
   882  		"subscriptionId":    client.SubscriptionID,
   883  	}
   884  
   885  	const APIVersion = "2017-06-01"
   886  	queryParameters := map[string]interface{}{
   887  		"api-version": APIVersion,
   888  	}
   889  
   890  	preparer := autorest.CreatePreparer(
   891  		autorest.AsPost(),
   892  		autorest.WithBaseURL(client.BaseURI),
   893  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/listFailoverSets", pathParameters),
   894  		autorest.WithQueryParameters(queryParameters))
   895  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   896  }
   897  
   898  // ListFailoverSetsSender sends the ListFailoverSets request. The method will close the
   899  // http.Response Body if it receives an error.
   900  func (client DevicesClient) ListFailoverSetsSender(req *http.Request) (*http.Response, error) {
   901  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   902  }
   903  
   904  // ListFailoverSetsResponder handles the response to the ListFailoverSets request. The method always
   905  // closes the http.Response Body.
   906  func (client DevicesClient) ListFailoverSetsResponder(resp *http.Response) (result FailoverSetsList, err error) {
   907  	err = autorest.Respond(
   908  		resp,
   909  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   910  		autorest.ByUnmarshallingJSON(&result),
   911  		autorest.ByClosing())
   912  	result.Response = autorest.Response{Response: resp}
   913  	return
   914  }
   915  
   916  // ListFailoverTargets given a list of volume containers to be failed over from a source device, this method returns
   917  // the eligibility result, as a failover target, for all devices under that resource.
   918  // Parameters:
   919  // sourceDeviceName - the source device name on which failover is performed.
   920  // parameters - listFailoverTargetsRequest containing the list of volume containers to be failed over.
   921  // resourceGroupName - the resource group name
   922  // managerName - the manager name
   923  func (client DevicesClient) ListFailoverTargets(ctx context.Context, sourceDeviceName string, parameters ListFailoverTargetsRequest, resourceGroupName string, managerName string) (result FailoverTargetsList, err error) {
   924  	if tracing.IsEnabled() {
   925  		ctx = tracing.StartSpan(ctx, fqdn+"/DevicesClient.ListFailoverTargets")
   926  		defer func() {
   927  			sc := -1
   928  			if result.Response.Response != nil {
   929  				sc = result.Response.Response.StatusCode
   930  			}
   931  			tracing.EndSpan(ctx, sc, err)
   932  		}()
   933  	}
   934  	if err := validation.Validate([]validation.Validation{
   935  		{TargetValue: managerName,
   936  			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   937  				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
   938  		return result, validation.NewError("storsimple.DevicesClient", "ListFailoverTargets", err.Error())
   939  	}
   940  
   941  	req, err := client.ListFailoverTargetsPreparer(ctx, sourceDeviceName, parameters, resourceGroupName, managerName)
   942  	if err != nil {
   943  		err = autorest.NewErrorWithError(err, "storsimple.DevicesClient", "ListFailoverTargets", nil, "Failure preparing request")
   944  		return
   945  	}
   946  
   947  	resp, err := client.ListFailoverTargetsSender(req)
   948  	if err != nil {
   949  		result.Response = autorest.Response{Response: resp}
   950  		err = autorest.NewErrorWithError(err, "storsimple.DevicesClient", "ListFailoverTargets", resp, "Failure sending request")
   951  		return
   952  	}
   953  
   954  	result, err = client.ListFailoverTargetsResponder(resp)
   955  	if err != nil {
   956  		err = autorest.NewErrorWithError(err, "storsimple.DevicesClient", "ListFailoverTargets", resp, "Failure responding to request")
   957  		return
   958  	}
   959  
   960  	return
   961  }
   962  
   963  // ListFailoverTargetsPreparer prepares the ListFailoverTargets request.
   964  func (client DevicesClient) ListFailoverTargetsPreparer(ctx context.Context, sourceDeviceName string, parameters ListFailoverTargetsRequest, resourceGroupName string, managerName string) (*http.Request, error) {
   965  	pathParameters := map[string]interface{}{
   966  		"managerName":       managerName,
   967  		"resourceGroupName": resourceGroupName,
   968  		"sourceDeviceName":  sourceDeviceName,
   969  		"subscriptionId":    client.SubscriptionID,
   970  	}
   971  
   972  	const APIVersion = "2017-06-01"
   973  	queryParameters := map[string]interface{}{
   974  		"api-version": APIVersion,
   975  	}
   976  
   977  	preparer := autorest.CreatePreparer(
   978  		autorest.AsContentType("application/json; charset=utf-8"),
   979  		autorest.AsPost(),
   980  		autorest.WithBaseURL(client.BaseURI),
   981  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{sourceDeviceName}/listFailoverTargets", pathParameters),
   982  		autorest.WithJSON(parameters),
   983  		autorest.WithQueryParameters(queryParameters))
   984  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   985  }
   986  
   987  // ListFailoverTargetsSender sends the ListFailoverTargets request. The method will close the
   988  // http.Response Body if it receives an error.
   989  func (client DevicesClient) ListFailoverTargetsSender(req *http.Request) (*http.Response, error) {
   990  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   991  }
   992  
   993  // ListFailoverTargetsResponder handles the response to the ListFailoverTargets request. The method always
   994  // closes the http.Response Body.
   995  func (client DevicesClient) ListFailoverTargetsResponder(resp *http.Response) (result FailoverTargetsList, err error) {
   996  	err = autorest.Respond(
   997  		resp,
   998  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   999  		autorest.ByUnmarshallingJSON(&result),
  1000  		autorest.ByClosing())
  1001  	result.Response = autorest.Response{Response: resp}
  1002  	return
  1003  }
  1004  
  1005  // ListMetricDefinition gets the metric definitions for the specified device.
  1006  // Parameters:
  1007  // deviceName - the device name
  1008  // resourceGroupName - the resource group name
  1009  // managerName - the manager name
  1010  func (client DevicesClient) ListMetricDefinition(ctx context.Context, deviceName string, resourceGroupName string, managerName string) (result MetricDefinitionList, err error) {
  1011  	if tracing.IsEnabled() {
  1012  		ctx = tracing.StartSpan(ctx, fqdn+"/DevicesClient.ListMetricDefinition")
  1013  		defer func() {
  1014  			sc := -1
  1015  			if result.Response.Response != nil {
  1016  				sc = result.Response.Response.StatusCode
  1017  			}
  1018  			tracing.EndSpan(ctx, sc, err)
  1019  		}()
  1020  	}
  1021  	if err := validation.Validate([]validation.Validation{
  1022  		{TargetValue: managerName,
  1023  			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
  1024  				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
  1025  		return result, validation.NewError("storsimple.DevicesClient", "ListMetricDefinition", err.Error())
  1026  	}
  1027  
  1028  	req, err := client.ListMetricDefinitionPreparer(ctx, deviceName, resourceGroupName, managerName)
  1029  	if err != nil {
  1030  		err = autorest.NewErrorWithError(err, "storsimple.DevicesClient", "ListMetricDefinition", nil, "Failure preparing request")
  1031  		return
  1032  	}
  1033  
  1034  	resp, err := client.ListMetricDefinitionSender(req)
  1035  	if err != nil {
  1036  		result.Response = autorest.Response{Response: resp}
  1037  		err = autorest.NewErrorWithError(err, "storsimple.DevicesClient", "ListMetricDefinition", resp, "Failure sending request")
  1038  		return
  1039  	}
  1040  
  1041  	result, err = client.ListMetricDefinitionResponder(resp)
  1042  	if err != nil {
  1043  		err = autorest.NewErrorWithError(err, "storsimple.DevicesClient", "ListMetricDefinition", resp, "Failure responding to request")
  1044  		return
  1045  	}
  1046  
  1047  	return
  1048  }
  1049  
  1050  // ListMetricDefinitionPreparer prepares the ListMetricDefinition request.
  1051  func (client DevicesClient) ListMetricDefinitionPreparer(ctx context.Context, deviceName string, resourceGroupName string, managerName string) (*http.Request, error) {
  1052  	pathParameters := map[string]interface{}{
  1053  		"deviceName":        deviceName,
  1054  		"managerName":       managerName,
  1055  		"resourceGroupName": resourceGroupName,
  1056  		"subscriptionId":    client.SubscriptionID,
  1057  	}
  1058  
  1059  	const APIVersion = "2017-06-01"
  1060  	queryParameters := map[string]interface{}{
  1061  		"api-version": APIVersion,
  1062  	}
  1063  
  1064  	preparer := autorest.CreatePreparer(
  1065  		autorest.AsGet(),
  1066  		autorest.WithBaseURL(client.BaseURI),
  1067  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/metricsDefinitions", pathParameters),
  1068  		autorest.WithQueryParameters(queryParameters))
  1069  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
  1070  }
  1071  
  1072  // ListMetricDefinitionSender sends the ListMetricDefinition request. The method will close the
  1073  // http.Response Body if it receives an error.
  1074  func (client DevicesClient) ListMetricDefinitionSender(req *http.Request) (*http.Response, error) {
  1075  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
  1076  }
  1077  
  1078  // ListMetricDefinitionResponder handles the response to the ListMetricDefinition request. The method always
  1079  // closes the http.Response Body.
  1080  func (client DevicesClient) ListMetricDefinitionResponder(resp *http.Response) (result MetricDefinitionList, err error) {
  1081  	err = autorest.Respond(
  1082  		resp,
  1083  		azure.WithErrorUnlessStatusCode(http.StatusOK),
  1084  		autorest.ByUnmarshallingJSON(&result),
  1085  		autorest.ByClosing())
  1086  	result.Response = autorest.Response{Response: resp}
  1087  	return
  1088  }
  1089  
  1090  // ListMetrics gets the metrics for the specified device.
  1091  // Parameters:
  1092  // deviceName - the device name
  1093  // resourceGroupName - the resource group name
  1094  // managerName - the manager name
  1095  // filter - oData Filter options
  1096  func (client DevicesClient) ListMetrics(ctx context.Context, deviceName string, resourceGroupName string, managerName string, filter string) (result MetricList, err error) {
  1097  	if tracing.IsEnabled() {
  1098  		ctx = tracing.StartSpan(ctx, fqdn+"/DevicesClient.ListMetrics")
  1099  		defer func() {
  1100  			sc := -1
  1101  			if result.Response.Response != nil {
  1102  				sc = result.Response.Response.StatusCode
  1103  			}
  1104  			tracing.EndSpan(ctx, sc, err)
  1105  		}()
  1106  	}
  1107  	if err := validation.Validate([]validation.Validation{
  1108  		{TargetValue: managerName,
  1109  			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
  1110  				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
  1111  		return result, validation.NewError("storsimple.DevicesClient", "ListMetrics", err.Error())
  1112  	}
  1113  
  1114  	req, err := client.ListMetricsPreparer(ctx, deviceName, resourceGroupName, managerName, filter)
  1115  	if err != nil {
  1116  		err = autorest.NewErrorWithError(err, "storsimple.DevicesClient", "ListMetrics", nil, "Failure preparing request")
  1117  		return
  1118  	}
  1119  
  1120  	resp, err := client.ListMetricsSender(req)
  1121  	if err != nil {
  1122  		result.Response = autorest.Response{Response: resp}
  1123  		err = autorest.NewErrorWithError(err, "storsimple.DevicesClient", "ListMetrics", resp, "Failure sending request")
  1124  		return
  1125  	}
  1126  
  1127  	result, err = client.ListMetricsResponder(resp)
  1128  	if err != nil {
  1129  		err = autorest.NewErrorWithError(err, "storsimple.DevicesClient", "ListMetrics", resp, "Failure responding to request")
  1130  		return
  1131  	}
  1132  
  1133  	return
  1134  }
  1135  
  1136  // ListMetricsPreparer prepares the ListMetrics request.
  1137  func (client DevicesClient) ListMetricsPreparer(ctx context.Context, deviceName string, resourceGroupName string, managerName string, filter string) (*http.Request, error) {
  1138  	pathParameters := map[string]interface{}{
  1139  		"deviceName":        deviceName,
  1140  		"managerName":       managerName,
  1141  		"resourceGroupName": resourceGroupName,
  1142  		"subscriptionId":    client.SubscriptionID,
  1143  	}
  1144  
  1145  	const APIVersion = "2017-06-01"
  1146  	queryParameters := map[string]interface{}{
  1147  		"$filter":     autorest.Encode("query", filter),
  1148  		"api-version": APIVersion,
  1149  	}
  1150  
  1151  	preparer := autorest.CreatePreparer(
  1152  		autorest.AsGet(),
  1153  		autorest.WithBaseURL(client.BaseURI),
  1154  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/metrics", pathParameters),
  1155  		autorest.WithQueryParameters(queryParameters))
  1156  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
  1157  }
  1158  
  1159  // ListMetricsSender sends the ListMetrics request. The method will close the
  1160  // http.Response Body if it receives an error.
  1161  func (client DevicesClient) ListMetricsSender(req *http.Request) (*http.Response, error) {
  1162  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
  1163  }
  1164  
  1165  // ListMetricsResponder handles the response to the ListMetrics request. The method always
  1166  // closes the http.Response Body.
  1167  func (client DevicesClient) ListMetricsResponder(resp *http.Response) (result MetricList, err error) {
  1168  	err = autorest.Respond(
  1169  		resp,
  1170  		azure.WithErrorUnlessStatusCode(http.StatusOK),
  1171  		autorest.ByUnmarshallingJSON(&result),
  1172  		autorest.ByClosing())
  1173  	result.Response = autorest.Response{Response: resp}
  1174  	return
  1175  }
  1176  
  1177  // ScanForUpdates scans for updates on the device.
  1178  // Parameters:
  1179  // deviceName - the device name
  1180  // resourceGroupName - the resource group name
  1181  // managerName - the manager name
  1182  func (client DevicesClient) ScanForUpdates(ctx context.Context, deviceName string, resourceGroupName string, managerName string) (result DevicesScanForUpdatesFuture, err error) {
  1183  	if tracing.IsEnabled() {
  1184  		ctx = tracing.StartSpan(ctx, fqdn+"/DevicesClient.ScanForUpdates")
  1185  		defer func() {
  1186  			sc := -1
  1187  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
  1188  				sc = result.FutureAPI.Response().StatusCode
  1189  			}
  1190  			tracing.EndSpan(ctx, sc, err)
  1191  		}()
  1192  	}
  1193  	if err := validation.Validate([]validation.Validation{
  1194  		{TargetValue: managerName,
  1195  			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
  1196  				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
  1197  		return result, validation.NewError("storsimple.DevicesClient", "ScanForUpdates", err.Error())
  1198  	}
  1199  
  1200  	req, err := client.ScanForUpdatesPreparer(ctx, deviceName, resourceGroupName, managerName)
  1201  	if err != nil {
  1202  		err = autorest.NewErrorWithError(err, "storsimple.DevicesClient", "ScanForUpdates", nil, "Failure preparing request")
  1203  		return
  1204  	}
  1205  
  1206  	result, err = client.ScanForUpdatesSender(req)
  1207  	if err != nil {
  1208  		err = autorest.NewErrorWithError(err, "storsimple.DevicesClient", "ScanForUpdates", result.Response(), "Failure sending request")
  1209  		return
  1210  	}
  1211  
  1212  	return
  1213  }
  1214  
  1215  // ScanForUpdatesPreparer prepares the ScanForUpdates request.
  1216  func (client DevicesClient) ScanForUpdatesPreparer(ctx context.Context, deviceName string, resourceGroupName string, managerName string) (*http.Request, error) {
  1217  	pathParameters := map[string]interface{}{
  1218  		"deviceName":        deviceName,
  1219  		"managerName":       managerName,
  1220  		"resourceGroupName": resourceGroupName,
  1221  		"subscriptionId":    client.SubscriptionID,
  1222  	}
  1223  
  1224  	const APIVersion = "2017-06-01"
  1225  	queryParameters := map[string]interface{}{
  1226  		"api-version": APIVersion,
  1227  	}
  1228  
  1229  	preparer := autorest.CreatePreparer(
  1230  		autorest.AsPost(),
  1231  		autorest.WithBaseURL(client.BaseURI),
  1232  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/scanForUpdates", pathParameters),
  1233  		autorest.WithQueryParameters(queryParameters))
  1234  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
  1235  }
  1236  
  1237  // ScanForUpdatesSender sends the ScanForUpdates request. The method will close the
  1238  // http.Response Body if it receives an error.
  1239  func (client DevicesClient) ScanForUpdatesSender(req *http.Request) (future DevicesScanForUpdatesFuture, err error) {
  1240  	var resp *http.Response
  1241  	future.FutureAPI = &azure.Future{}
  1242  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
  1243  	if err != nil {
  1244  		return
  1245  	}
  1246  	var azf azure.Future
  1247  	azf, err = azure.NewFutureFromResponse(resp)
  1248  	future.FutureAPI = &azf
  1249  	future.Result = future.result
  1250  	return
  1251  }
  1252  
  1253  // ScanForUpdatesResponder handles the response to the ScanForUpdates request. The method always
  1254  // closes the http.Response Body.
  1255  func (client DevicesClient) ScanForUpdatesResponder(resp *http.Response) (result autorest.Response, err error) {
  1256  	err = autorest.Respond(
  1257  		resp,
  1258  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
  1259  		autorest.ByClosing())
  1260  	result.Response = resp
  1261  	return
  1262  }
  1263  
  1264  // Update patches the device.
  1265  // Parameters:
  1266  // deviceName - the device name
  1267  // parameters - patch representation of the device.
  1268  // resourceGroupName - the resource group name
  1269  // managerName - the manager name
  1270  func (client DevicesClient) Update(ctx context.Context, deviceName string, parameters DevicePatch, resourceGroupName string, managerName string) (result Device, err error) {
  1271  	if tracing.IsEnabled() {
  1272  		ctx = tracing.StartSpan(ctx, fqdn+"/DevicesClient.Update")
  1273  		defer func() {
  1274  			sc := -1
  1275  			if result.Response.Response != nil {
  1276  				sc = result.Response.Response.StatusCode
  1277  			}
  1278  			tracing.EndSpan(ctx, sc, err)
  1279  		}()
  1280  	}
  1281  	if err := validation.Validate([]validation.Validation{
  1282  		{TargetValue: managerName,
  1283  			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
  1284  				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
  1285  		return result, validation.NewError("storsimple.DevicesClient", "Update", err.Error())
  1286  	}
  1287  
  1288  	req, err := client.UpdatePreparer(ctx, deviceName, parameters, resourceGroupName, managerName)
  1289  	if err != nil {
  1290  		err = autorest.NewErrorWithError(err, "storsimple.DevicesClient", "Update", nil, "Failure preparing request")
  1291  		return
  1292  	}
  1293  
  1294  	resp, err := client.UpdateSender(req)
  1295  	if err != nil {
  1296  		result.Response = autorest.Response{Response: resp}
  1297  		err = autorest.NewErrorWithError(err, "storsimple.DevicesClient", "Update", resp, "Failure sending request")
  1298  		return
  1299  	}
  1300  
  1301  	result, err = client.UpdateResponder(resp)
  1302  	if err != nil {
  1303  		err = autorest.NewErrorWithError(err, "storsimple.DevicesClient", "Update", resp, "Failure responding to request")
  1304  		return
  1305  	}
  1306  
  1307  	return
  1308  }
  1309  
  1310  // UpdatePreparer prepares the Update request.
  1311  func (client DevicesClient) UpdatePreparer(ctx context.Context, deviceName string, parameters DevicePatch, resourceGroupName string, managerName string) (*http.Request, error) {
  1312  	pathParameters := map[string]interface{}{
  1313  		"deviceName":        deviceName,
  1314  		"managerName":       managerName,
  1315  		"resourceGroupName": resourceGroupName,
  1316  		"subscriptionId":    client.SubscriptionID,
  1317  	}
  1318  
  1319  	const APIVersion = "2017-06-01"
  1320  	queryParameters := map[string]interface{}{
  1321  		"api-version": APIVersion,
  1322  	}
  1323  
  1324  	preparer := autorest.CreatePreparer(
  1325  		autorest.AsContentType("application/json; charset=utf-8"),
  1326  		autorest.AsPatch(),
  1327  		autorest.WithBaseURL(client.BaseURI),
  1328  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}", pathParameters),
  1329  		autorest.WithJSON(parameters),
  1330  		autorest.WithQueryParameters(queryParameters))
  1331  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
  1332  }
  1333  
  1334  // UpdateSender sends the Update request. The method will close the
  1335  // http.Response Body if it receives an error.
  1336  func (client DevicesClient) UpdateSender(req *http.Request) (*http.Response, error) {
  1337  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
  1338  }
  1339  
  1340  // UpdateResponder handles the response to the Update request. The method always
  1341  // closes the http.Response Body.
  1342  func (client DevicesClient) UpdateResponder(resp *http.Response) (result Device, err error) {
  1343  	err = autorest.Respond(
  1344  		resp,
  1345  		azure.WithErrorUnlessStatusCode(http.StatusOK),
  1346  		autorest.ByUnmarshallingJSON(&result),
  1347  		autorest.ByClosing())
  1348  	result.Response = autorest.Response{Response: resp}
  1349  	return
  1350  }
  1351  

View as plain text