...

Source file src/github.com/Azure/azure-sdk-for-go/services/storsimple1200series/mgmt/2016-10-01/storsimple/iscsidisks.go

Documentation: github.com/Azure/azure-sdk-for-go/services/storsimple1200series/mgmt/2016-10-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  // IscsiDisksClient is the client for the IscsiDisks methods of the Storsimple service.
    19  type IscsiDisksClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewIscsiDisksClient creates an instance of the IscsiDisksClient client.
    24  func NewIscsiDisksClient(subscriptionID string) IscsiDisksClient {
    25  	return NewIscsiDisksClientWithBaseURI(DefaultBaseURI, subscriptionID)
    26  }
    27  
    28  // NewIscsiDisksClientWithBaseURI creates an instance of the IscsiDisksClient client using a custom endpoint.  Use this
    29  // when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
    30  func NewIscsiDisksClientWithBaseURI(baseURI string, subscriptionID string) IscsiDisksClient {
    31  	return IscsiDisksClient{NewWithBaseURI(baseURI, subscriptionID)}
    32  }
    33  
    34  // CreateOrUpdate creates or updates the iSCSI disk.
    35  // Parameters:
    36  // deviceName - the device name.
    37  // iscsiServerName - the iSCSI server name.
    38  // diskName - the disk name.
    39  // iscsiDisk - the iSCSI disk.
    40  // resourceGroupName - the resource group name
    41  // managerName - the manager name
    42  func (client IscsiDisksClient) CreateOrUpdate(ctx context.Context, deviceName string, iscsiServerName string, diskName string, iscsiDisk ISCSIDisk, resourceGroupName string, managerName string) (result IscsiDisksCreateOrUpdateFuture, err error) {
    43  	if tracing.IsEnabled() {
    44  		ctx = tracing.StartSpan(ctx, fqdn+"/IscsiDisksClient.CreateOrUpdate")
    45  		defer func() {
    46  			sc := -1
    47  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
    48  				sc = result.FutureAPI.Response().StatusCode
    49  			}
    50  			tracing.EndSpan(ctx, sc, err)
    51  		}()
    52  	}
    53  	if err := validation.Validate([]validation.Validation{
    54  		{TargetValue: iscsiDisk,
    55  			Constraints: []validation.Constraint{{Target: "iscsiDisk.ISCSIDiskProperties", Name: validation.Null, Rule: true,
    56  				Chain: []validation.Constraint{{Target: "iscsiDisk.ISCSIDiskProperties.AccessControlRecords", Name: validation.Null, Rule: true, Chain: nil},
    57  					{Target: "iscsiDisk.ISCSIDiskProperties.ProvisionedCapacityInBytes", Name: validation.Null, Rule: true, Chain: nil},
    58  				}}}},
    59  		{TargetValue: managerName,
    60  			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
    61  				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
    62  		return result, validation.NewError("storsimple.IscsiDisksClient", "CreateOrUpdate", err.Error())
    63  	}
    64  
    65  	req, err := client.CreateOrUpdatePreparer(ctx, deviceName, iscsiServerName, diskName, iscsiDisk, resourceGroupName, managerName)
    66  	if err != nil {
    67  		err = autorest.NewErrorWithError(err, "storsimple.IscsiDisksClient", "CreateOrUpdate", nil, "Failure preparing request")
    68  		return
    69  	}
    70  
    71  	result, err = client.CreateOrUpdateSender(req)
    72  	if err != nil {
    73  		err = autorest.NewErrorWithError(err, "storsimple.IscsiDisksClient", "CreateOrUpdate", result.Response(), "Failure sending request")
    74  		return
    75  	}
    76  
    77  	return
    78  }
    79  
    80  // CreateOrUpdatePreparer prepares the CreateOrUpdate request.
    81  func (client IscsiDisksClient) CreateOrUpdatePreparer(ctx context.Context, deviceName string, iscsiServerName string, diskName string, iscsiDisk ISCSIDisk, resourceGroupName string, managerName string) (*http.Request, error) {
    82  	pathParameters := map[string]interface{}{
    83  		"deviceName":        autorest.Encode("path", deviceName),
    84  		"diskName":          autorest.Encode("path", diskName),
    85  		"iscsiServerName":   autorest.Encode("path", iscsiServerName),
    86  		"managerName":       autorest.Encode("path", managerName),
    87  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
    88  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
    89  	}
    90  
    91  	const APIVersion = "2016-10-01"
    92  	queryParameters := map[string]interface{}{
    93  		"api-version": APIVersion,
    94  	}
    95  
    96  	preparer := autorest.CreatePreparer(
    97  		autorest.AsContentType("application/json; charset=utf-8"),
    98  		autorest.AsPut(),
    99  		autorest.WithBaseURL(client.BaseURI),
   100  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/iscsiservers/{iscsiServerName}/disks/{diskName}", pathParameters),
   101  		autorest.WithJSON(iscsiDisk),
   102  		autorest.WithQueryParameters(queryParameters))
   103  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   104  }
   105  
   106  // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
   107  // http.Response Body if it receives an error.
   108  func (client IscsiDisksClient) CreateOrUpdateSender(req *http.Request) (future IscsiDisksCreateOrUpdateFuture, err error) {
   109  	var resp *http.Response
   110  	future.FutureAPI = &azure.Future{}
   111  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   112  	if err != nil {
   113  		return
   114  	}
   115  	var azf azure.Future
   116  	azf, err = azure.NewFutureFromResponse(resp)
   117  	future.FutureAPI = &azf
   118  	future.Result = future.result
   119  	return
   120  }
   121  
   122  // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
   123  // closes the http.Response Body.
   124  func (client IscsiDisksClient) CreateOrUpdateResponder(resp *http.Response) (result ISCSIDisk, err error) {
   125  	err = autorest.Respond(
   126  		resp,
   127  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   128  		autorest.ByUnmarshallingJSON(&result),
   129  		autorest.ByClosing())
   130  	result.Response = autorest.Response{Response: resp}
   131  	return
   132  }
   133  
   134  // Delete deletes the iSCSI disk.
   135  // Parameters:
   136  // deviceName - the device name.
   137  // iscsiServerName - the iSCSI server name.
   138  // diskName - the disk name.
   139  // resourceGroupName - the resource group name
   140  // managerName - the manager name
   141  func (client IscsiDisksClient) Delete(ctx context.Context, deviceName string, iscsiServerName string, diskName string, resourceGroupName string, managerName string) (result IscsiDisksDeleteFuture, err error) {
   142  	if tracing.IsEnabled() {
   143  		ctx = tracing.StartSpan(ctx, fqdn+"/IscsiDisksClient.Delete")
   144  		defer func() {
   145  			sc := -1
   146  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   147  				sc = result.FutureAPI.Response().StatusCode
   148  			}
   149  			tracing.EndSpan(ctx, sc, err)
   150  		}()
   151  	}
   152  	if err := validation.Validate([]validation.Validation{
   153  		{TargetValue: managerName,
   154  			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   155  				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
   156  		return result, validation.NewError("storsimple.IscsiDisksClient", "Delete", err.Error())
   157  	}
   158  
   159  	req, err := client.DeletePreparer(ctx, deviceName, iscsiServerName, diskName, resourceGroupName, managerName)
   160  	if err != nil {
   161  		err = autorest.NewErrorWithError(err, "storsimple.IscsiDisksClient", "Delete", nil, "Failure preparing request")
   162  		return
   163  	}
   164  
   165  	result, err = client.DeleteSender(req)
   166  	if err != nil {
   167  		err = autorest.NewErrorWithError(err, "storsimple.IscsiDisksClient", "Delete", result.Response(), "Failure sending request")
   168  		return
   169  	}
   170  
   171  	return
   172  }
   173  
   174  // DeletePreparer prepares the Delete request.
   175  func (client IscsiDisksClient) DeletePreparer(ctx context.Context, deviceName string, iscsiServerName string, diskName string, resourceGroupName string, managerName string) (*http.Request, error) {
   176  	pathParameters := map[string]interface{}{
   177  		"deviceName":        autorest.Encode("path", deviceName),
   178  		"diskName":          autorest.Encode("path", diskName),
   179  		"iscsiServerName":   autorest.Encode("path", iscsiServerName),
   180  		"managerName":       autorest.Encode("path", managerName),
   181  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   182  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   183  	}
   184  
   185  	const APIVersion = "2016-10-01"
   186  	queryParameters := map[string]interface{}{
   187  		"api-version": APIVersion,
   188  	}
   189  
   190  	preparer := autorest.CreatePreparer(
   191  		autorest.AsDelete(),
   192  		autorest.WithBaseURL(client.BaseURI),
   193  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/iscsiservers/{iscsiServerName}/disks/{diskName}", pathParameters),
   194  		autorest.WithQueryParameters(queryParameters))
   195  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   196  }
   197  
   198  // DeleteSender sends the Delete request. The method will close the
   199  // http.Response Body if it receives an error.
   200  func (client IscsiDisksClient) DeleteSender(req *http.Request) (future IscsiDisksDeleteFuture, err error) {
   201  	var resp *http.Response
   202  	future.FutureAPI = &azure.Future{}
   203  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   204  	if err != nil {
   205  		return
   206  	}
   207  	var azf azure.Future
   208  	azf, err = azure.NewFutureFromResponse(resp)
   209  	future.FutureAPI = &azf
   210  	future.Result = future.result
   211  	return
   212  }
   213  
   214  // DeleteResponder handles the response to the Delete request. The method always
   215  // closes the http.Response Body.
   216  func (client IscsiDisksClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
   217  	err = autorest.Respond(
   218  		resp,
   219  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   220  		autorest.ByClosing())
   221  	result.Response = resp
   222  	return
   223  }
   224  
   225  // Get returns the properties of the specified iSCSI disk name.
   226  // Parameters:
   227  // deviceName - the device name.
   228  // iscsiServerName - the iSCSI server name.
   229  // diskName - the disk name.
   230  // resourceGroupName - the resource group name
   231  // managerName - the manager name
   232  func (client IscsiDisksClient) Get(ctx context.Context, deviceName string, iscsiServerName string, diskName string, resourceGroupName string, managerName string) (result ISCSIDisk, err error) {
   233  	if tracing.IsEnabled() {
   234  		ctx = tracing.StartSpan(ctx, fqdn+"/IscsiDisksClient.Get")
   235  		defer func() {
   236  			sc := -1
   237  			if result.Response.Response != nil {
   238  				sc = result.Response.Response.StatusCode
   239  			}
   240  			tracing.EndSpan(ctx, sc, err)
   241  		}()
   242  	}
   243  	if err := validation.Validate([]validation.Validation{
   244  		{TargetValue: managerName,
   245  			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   246  				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
   247  		return result, validation.NewError("storsimple.IscsiDisksClient", "Get", err.Error())
   248  	}
   249  
   250  	req, err := client.GetPreparer(ctx, deviceName, iscsiServerName, diskName, resourceGroupName, managerName)
   251  	if err != nil {
   252  		err = autorest.NewErrorWithError(err, "storsimple.IscsiDisksClient", "Get", nil, "Failure preparing request")
   253  		return
   254  	}
   255  
   256  	resp, err := client.GetSender(req)
   257  	if err != nil {
   258  		result.Response = autorest.Response{Response: resp}
   259  		err = autorest.NewErrorWithError(err, "storsimple.IscsiDisksClient", "Get", resp, "Failure sending request")
   260  		return
   261  	}
   262  
   263  	result, err = client.GetResponder(resp)
   264  	if err != nil {
   265  		err = autorest.NewErrorWithError(err, "storsimple.IscsiDisksClient", "Get", resp, "Failure responding to request")
   266  		return
   267  	}
   268  
   269  	return
   270  }
   271  
   272  // GetPreparer prepares the Get request.
   273  func (client IscsiDisksClient) GetPreparer(ctx context.Context, deviceName string, iscsiServerName string, diskName string, resourceGroupName string, managerName string) (*http.Request, error) {
   274  	pathParameters := map[string]interface{}{
   275  		"deviceName":        autorest.Encode("path", deviceName),
   276  		"diskName":          autorest.Encode("path", diskName),
   277  		"iscsiServerName":   autorest.Encode("path", iscsiServerName),
   278  		"managerName":       autorest.Encode("path", managerName),
   279  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   280  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   281  	}
   282  
   283  	const APIVersion = "2016-10-01"
   284  	queryParameters := map[string]interface{}{
   285  		"api-version": APIVersion,
   286  	}
   287  
   288  	preparer := autorest.CreatePreparer(
   289  		autorest.AsGet(),
   290  		autorest.WithBaseURL(client.BaseURI),
   291  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/iscsiservers/{iscsiServerName}/disks/{diskName}", pathParameters),
   292  		autorest.WithQueryParameters(queryParameters))
   293  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   294  }
   295  
   296  // GetSender sends the Get request. The method will close the
   297  // http.Response Body if it receives an error.
   298  func (client IscsiDisksClient) GetSender(req *http.Request) (*http.Response, error) {
   299  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   300  }
   301  
   302  // GetResponder handles the response to the Get request. The method always
   303  // closes the http.Response Body.
   304  func (client IscsiDisksClient) GetResponder(resp *http.Response) (result ISCSIDisk, err error) {
   305  	err = autorest.Respond(
   306  		resp,
   307  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   308  		autorest.ByUnmarshallingJSON(&result),
   309  		autorest.ByClosing())
   310  	result.Response = autorest.Response{Response: resp}
   311  	return
   312  }
   313  
   314  // ListByDevice retrieves all the iSCSI disks in a device.
   315  // Parameters:
   316  // deviceName - the device name.
   317  // resourceGroupName - the resource group name
   318  // managerName - the manager name
   319  func (client IscsiDisksClient) ListByDevice(ctx context.Context, deviceName string, resourceGroupName string, managerName string) (result ISCSIDiskList, err error) {
   320  	if tracing.IsEnabled() {
   321  		ctx = tracing.StartSpan(ctx, fqdn+"/IscsiDisksClient.ListByDevice")
   322  		defer func() {
   323  			sc := -1
   324  			if result.Response.Response != nil {
   325  				sc = result.Response.Response.StatusCode
   326  			}
   327  			tracing.EndSpan(ctx, sc, err)
   328  		}()
   329  	}
   330  	if err := validation.Validate([]validation.Validation{
   331  		{TargetValue: managerName,
   332  			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   333  				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
   334  		return result, validation.NewError("storsimple.IscsiDisksClient", "ListByDevice", err.Error())
   335  	}
   336  
   337  	req, err := client.ListByDevicePreparer(ctx, deviceName, resourceGroupName, managerName)
   338  	if err != nil {
   339  		err = autorest.NewErrorWithError(err, "storsimple.IscsiDisksClient", "ListByDevice", nil, "Failure preparing request")
   340  		return
   341  	}
   342  
   343  	resp, err := client.ListByDeviceSender(req)
   344  	if err != nil {
   345  		result.Response = autorest.Response{Response: resp}
   346  		err = autorest.NewErrorWithError(err, "storsimple.IscsiDisksClient", "ListByDevice", resp, "Failure sending request")
   347  		return
   348  	}
   349  
   350  	result, err = client.ListByDeviceResponder(resp)
   351  	if err != nil {
   352  		err = autorest.NewErrorWithError(err, "storsimple.IscsiDisksClient", "ListByDevice", resp, "Failure responding to request")
   353  		return
   354  	}
   355  
   356  	return
   357  }
   358  
   359  // ListByDevicePreparer prepares the ListByDevice request.
   360  func (client IscsiDisksClient) ListByDevicePreparer(ctx context.Context, deviceName string, resourceGroupName string, managerName string) (*http.Request, error) {
   361  	pathParameters := map[string]interface{}{
   362  		"deviceName":        autorest.Encode("path", deviceName),
   363  		"managerName":       autorest.Encode("path", managerName),
   364  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   365  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   366  	}
   367  
   368  	const APIVersion = "2016-10-01"
   369  	queryParameters := map[string]interface{}{
   370  		"api-version": APIVersion,
   371  	}
   372  
   373  	preparer := autorest.CreatePreparer(
   374  		autorest.AsGet(),
   375  		autorest.WithBaseURL(client.BaseURI),
   376  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/disks", pathParameters),
   377  		autorest.WithQueryParameters(queryParameters))
   378  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   379  }
   380  
   381  // ListByDeviceSender sends the ListByDevice request. The method will close the
   382  // http.Response Body if it receives an error.
   383  func (client IscsiDisksClient) ListByDeviceSender(req *http.Request) (*http.Response, error) {
   384  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   385  }
   386  
   387  // ListByDeviceResponder handles the response to the ListByDevice request. The method always
   388  // closes the http.Response Body.
   389  func (client IscsiDisksClient) ListByDeviceResponder(resp *http.Response) (result ISCSIDiskList, err error) {
   390  	err = autorest.Respond(
   391  		resp,
   392  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   393  		autorest.ByUnmarshallingJSON(&result),
   394  		autorest.ByClosing())
   395  	result.Response = autorest.Response{Response: resp}
   396  	return
   397  }
   398  
   399  // ListByIscsiServer retrieves all the disks in a iSCSI server.
   400  // Parameters:
   401  // deviceName - the device name.
   402  // iscsiServerName - the iSCSI server name.
   403  // resourceGroupName - the resource group name
   404  // managerName - the manager name
   405  func (client IscsiDisksClient) ListByIscsiServer(ctx context.Context, deviceName string, iscsiServerName string, resourceGroupName string, managerName string) (result ISCSIDiskList, err error) {
   406  	if tracing.IsEnabled() {
   407  		ctx = tracing.StartSpan(ctx, fqdn+"/IscsiDisksClient.ListByIscsiServer")
   408  		defer func() {
   409  			sc := -1
   410  			if result.Response.Response != nil {
   411  				sc = result.Response.Response.StatusCode
   412  			}
   413  			tracing.EndSpan(ctx, sc, err)
   414  		}()
   415  	}
   416  	if err := validation.Validate([]validation.Validation{
   417  		{TargetValue: managerName,
   418  			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   419  				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
   420  		return result, validation.NewError("storsimple.IscsiDisksClient", "ListByIscsiServer", err.Error())
   421  	}
   422  
   423  	req, err := client.ListByIscsiServerPreparer(ctx, deviceName, iscsiServerName, resourceGroupName, managerName)
   424  	if err != nil {
   425  		err = autorest.NewErrorWithError(err, "storsimple.IscsiDisksClient", "ListByIscsiServer", nil, "Failure preparing request")
   426  		return
   427  	}
   428  
   429  	resp, err := client.ListByIscsiServerSender(req)
   430  	if err != nil {
   431  		result.Response = autorest.Response{Response: resp}
   432  		err = autorest.NewErrorWithError(err, "storsimple.IscsiDisksClient", "ListByIscsiServer", resp, "Failure sending request")
   433  		return
   434  	}
   435  
   436  	result, err = client.ListByIscsiServerResponder(resp)
   437  	if err != nil {
   438  		err = autorest.NewErrorWithError(err, "storsimple.IscsiDisksClient", "ListByIscsiServer", resp, "Failure responding to request")
   439  		return
   440  	}
   441  
   442  	return
   443  }
   444  
   445  // ListByIscsiServerPreparer prepares the ListByIscsiServer request.
   446  func (client IscsiDisksClient) ListByIscsiServerPreparer(ctx context.Context, deviceName string, iscsiServerName string, resourceGroupName string, managerName string) (*http.Request, error) {
   447  	pathParameters := map[string]interface{}{
   448  		"deviceName":        autorest.Encode("path", deviceName),
   449  		"iscsiServerName":   autorest.Encode("path", iscsiServerName),
   450  		"managerName":       autorest.Encode("path", managerName),
   451  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   452  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   453  	}
   454  
   455  	const APIVersion = "2016-10-01"
   456  	queryParameters := map[string]interface{}{
   457  		"api-version": APIVersion,
   458  	}
   459  
   460  	preparer := autorest.CreatePreparer(
   461  		autorest.AsGet(),
   462  		autorest.WithBaseURL(client.BaseURI),
   463  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/iscsiservers/{iscsiServerName}/disks", pathParameters),
   464  		autorest.WithQueryParameters(queryParameters))
   465  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   466  }
   467  
   468  // ListByIscsiServerSender sends the ListByIscsiServer request. The method will close the
   469  // http.Response Body if it receives an error.
   470  func (client IscsiDisksClient) ListByIscsiServerSender(req *http.Request) (*http.Response, error) {
   471  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   472  }
   473  
   474  // ListByIscsiServerResponder handles the response to the ListByIscsiServer request. The method always
   475  // closes the http.Response Body.
   476  func (client IscsiDisksClient) ListByIscsiServerResponder(resp *http.Response) (result ISCSIDiskList, err error) {
   477  	err = autorest.Respond(
   478  		resp,
   479  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   480  		autorest.ByUnmarshallingJSON(&result),
   481  		autorest.ByClosing())
   482  	result.Response = autorest.Response{Response: resp}
   483  	return
   484  }
   485  
   486  // ListMetricDefinition retrieves metric definitions for all metric aggregated at the iSCSI disk.
   487  // Parameters:
   488  // deviceName - the device name.
   489  // iscsiServerName - the iSCSI server name.
   490  // diskName - the iSCSI disk name.
   491  // resourceGroupName - the resource group name
   492  // managerName - the manager name
   493  func (client IscsiDisksClient) ListMetricDefinition(ctx context.Context, deviceName string, iscsiServerName string, diskName string, resourceGroupName string, managerName string) (result MetricDefinitionList, err error) {
   494  	if tracing.IsEnabled() {
   495  		ctx = tracing.StartSpan(ctx, fqdn+"/IscsiDisksClient.ListMetricDefinition")
   496  		defer func() {
   497  			sc := -1
   498  			if result.Response.Response != nil {
   499  				sc = result.Response.Response.StatusCode
   500  			}
   501  			tracing.EndSpan(ctx, sc, err)
   502  		}()
   503  	}
   504  	if err := validation.Validate([]validation.Validation{
   505  		{TargetValue: managerName,
   506  			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   507  				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
   508  		return result, validation.NewError("storsimple.IscsiDisksClient", "ListMetricDefinition", err.Error())
   509  	}
   510  
   511  	req, err := client.ListMetricDefinitionPreparer(ctx, deviceName, iscsiServerName, diskName, resourceGroupName, managerName)
   512  	if err != nil {
   513  		err = autorest.NewErrorWithError(err, "storsimple.IscsiDisksClient", "ListMetricDefinition", nil, "Failure preparing request")
   514  		return
   515  	}
   516  
   517  	resp, err := client.ListMetricDefinitionSender(req)
   518  	if err != nil {
   519  		result.Response = autorest.Response{Response: resp}
   520  		err = autorest.NewErrorWithError(err, "storsimple.IscsiDisksClient", "ListMetricDefinition", resp, "Failure sending request")
   521  		return
   522  	}
   523  
   524  	result, err = client.ListMetricDefinitionResponder(resp)
   525  	if err != nil {
   526  		err = autorest.NewErrorWithError(err, "storsimple.IscsiDisksClient", "ListMetricDefinition", resp, "Failure responding to request")
   527  		return
   528  	}
   529  
   530  	return
   531  }
   532  
   533  // ListMetricDefinitionPreparer prepares the ListMetricDefinition request.
   534  func (client IscsiDisksClient) ListMetricDefinitionPreparer(ctx context.Context, deviceName string, iscsiServerName string, diskName string, resourceGroupName string, managerName string) (*http.Request, error) {
   535  	pathParameters := map[string]interface{}{
   536  		"deviceName":        autorest.Encode("path", deviceName),
   537  		"diskName":          autorest.Encode("path", diskName),
   538  		"iscsiServerName":   autorest.Encode("path", iscsiServerName),
   539  		"managerName":       autorest.Encode("path", managerName),
   540  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   541  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   542  	}
   543  
   544  	const APIVersion = "2016-10-01"
   545  	queryParameters := map[string]interface{}{
   546  		"api-version": APIVersion,
   547  	}
   548  
   549  	preparer := autorest.CreatePreparer(
   550  		autorest.AsGet(),
   551  		autorest.WithBaseURL(client.BaseURI),
   552  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/iscsiservers/{iscsiServerName}/disks/{diskName}/metricsDefinitions", pathParameters),
   553  		autorest.WithQueryParameters(queryParameters))
   554  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   555  }
   556  
   557  // ListMetricDefinitionSender sends the ListMetricDefinition request. The method will close the
   558  // http.Response Body if it receives an error.
   559  func (client IscsiDisksClient) ListMetricDefinitionSender(req *http.Request) (*http.Response, error) {
   560  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   561  }
   562  
   563  // ListMetricDefinitionResponder handles the response to the ListMetricDefinition request. The method always
   564  // closes the http.Response Body.
   565  func (client IscsiDisksClient) ListMetricDefinitionResponder(resp *http.Response) (result MetricDefinitionList, err error) {
   566  	err = autorest.Respond(
   567  		resp,
   568  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   569  		autorest.ByUnmarshallingJSON(&result),
   570  		autorest.ByClosing())
   571  	result.Response = autorest.Response{Response: resp}
   572  	return
   573  }
   574  
   575  // ListMetrics gets the iSCSI disk metrics
   576  // Parameters:
   577  // deviceName - the device name.
   578  // iscsiServerName - the iSCSI server name.
   579  // diskName - the iSCSI disk name.
   580  // resourceGroupName - the resource group name
   581  // managerName - the manager name
   582  // filter - oData Filter options
   583  func (client IscsiDisksClient) ListMetrics(ctx context.Context, deviceName string, iscsiServerName string, diskName string, resourceGroupName string, managerName string, filter string) (result MetricList, err error) {
   584  	if tracing.IsEnabled() {
   585  		ctx = tracing.StartSpan(ctx, fqdn+"/IscsiDisksClient.ListMetrics")
   586  		defer func() {
   587  			sc := -1
   588  			if result.Response.Response != nil {
   589  				sc = result.Response.Response.StatusCode
   590  			}
   591  			tracing.EndSpan(ctx, sc, err)
   592  		}()
   593  	}
   594  	if err := validation.Validate([]validation.Validation{
   595  		{TargetValue: managerName,
   596  			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   597  				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
   598  		return result, validation.NewError("storsimple.IscsiDisksClient", "ListMetrics", err.Error())
   599  	}
   600  
   601  	req, err := client.ListMetricsPreparer(ctx, deviceName, iscsiServerName, diskName, resourceGroupName, managerName, filter)
   602  	if err != nil {
   603  		err = autorest.NewErrorWithError(err, "storsimple.IscsiDisksClient", "ListMetrics", nil, "Failure preparing request")
   604  		return
   605  	}
   606  
   607  	resp, err := client.ListMetricsSender(req)
   608  	if err != nil {
   609  		result.Response = autorest.Response{Response: resp}
   610  		err = autorest.NewErrorWithError(err, "storsimple.IscsiDisksClient", "ListMetrics", resp, "Failure sending request")
   611  		return
   612  	}
   613  
   614  	result, err = client.ListMetricsResponder(resp)
   615  	if err != nil {
   616  		err = autorest.NewErrorWithError(err, "storsimple.IscsiDisksClient", "ListMetrics", resp, "Failure responding to request")
   617  		return
   618  	}
   619  
   620  	return
   621  }
   622  
   623  // ListMetricsPreparer prepares the ListMetrics request.
   624  func (client IscsiDisksClient) ListMetricsPreparer(ctx context.Context, deviceName string, iscsiServerName string, diskName string, resourceGroupName string, managerName string, filter string) (*http.Request, error) {
   625  	pathParameters := map[string]interface{}{
   626  		"deviceName":        autorest.Encode("path", deviceName),
   627  		"diskName":          autorest.Encode("path", diskName),
   628  		"iscsiServerName":   autorest.Encode("path", iscsiServerName),
   629  		"managerName":       autorest.Encode("path", managerName),
   630  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   631  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   632  	}
   633  
   634  	const APIVersion = "2016-10-01"
   635  	queryParameters := map[string]interface{}{
   636  		"api-version": APIVersion,
   637  	}
   638  	if len(filter) > 0 {
   639  		queryParameters["$filter"] = autorest.Encode("query", filter)
   640  	}
   641  
   642  	preparer := autorest.CreatePreparer(
   643  		autorest.AsGet(),
   644  		autorest.WithBaseURL(client.BaseURI),
   645  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/iscsiservers/{iscsiServerName}/disks/{diskName}/metrics", pathParameters),
   646  		autorest.WithQueryParameters(queryParameters))
   647  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   648  }
   649  
   650  // ListMetricsSender sends the ListMetrics request. The method will close the
   651  // http.Response Body if it receives an error.
   652  func (client IscsiDisksClient) ListMetricsSender(req *http.Request) (*http.Response, error) {
   653  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   654  }
   655  
   656  // ListMetricsResponder handles the response to the ListMetrics request. The method always
   657  // closes the http.Response Body.
   658  func (client IscsiDisksClient) ListMetricsResponder(resp *http.Response) (result MetricList, err error) {
   659  	err = autorest.Respond(
   660  		resp,
   661  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   662  		autorest.ByUnmarshallingJSON(&result),
   663  		autorest.ByClosing())
   664  	result.Response = autorest.Response{Response: resp}
   665  	return
   666  }
   667  

View as plain text