...

Source file src/github.com/Azure/azure-sdk-for-go/services/storsimple8000series/mgmt/2017-06-01/storsimple/cloudappliances.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  // CloudAppliancesClient is the client for the CloudAppliances methods of the Storsimple service.
    19  type CloudAppliancesClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewCloudAppliancesClient creates an instance of the CloudAppliancesClient client.
    24  func NewCloudAppliancesClient(subscriptionID string) CloudAppliancesClient {
    25  	return NewCloudAppliancesClientWithBaseURI(DefaultBaseURI, subscriptionID)
    26  }
    27  
    28  // NewCloudAppliancesClientWithBaseURI creates an instance of the CloudAppliancesClient client using a custom endpoint.
    29  // Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
    30  func NewCloudAppliancesClientWithBaseURI(baseURI string, subscriptionID string) CloudAppliancesClient {
    31  	return CloudAppliancesClient{NewWithBaseURI(baseURI, subscriptionID)}
    32  }
    33  
    34  // ListSupportedConfigurations lists supported cloud appliance models and supported configurations.
    35  // Parameters:
    36  // resourceGroupName - the resource group name
    37  // managerName - the manager name
    38  func (client CloudAppliancesClient) ListSupportedConfigurations(ctx context.Context, resourceGroupName string, managerName string) (result CloudApplianceConfigurationList, err error) {
    39  	if tracing.IsEnabled() {
    40  		ctx = tracing.StartSpan(ctx, fqdn+"/CloudAppliancesClient.ListSupportedConfigurations")
    41  		defer func() {
    42  			sc := -1
    43  			if result.Response.Response != nil {
    44  				sc = result.Response.Response.StatusCode
    45  			}
    46  			tracing.EndSpan(ctx, sc, err)
    47  		}()
    48  	}
    49  	if err := validation.Validate([]validation.Validation{
    50  		{TargetValue: managerName,
    51  			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
    52  				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
    53  		return result, validation.NewError("storsimple.CloudAppliancesClient", "ListSupportedConfigurations", err.Error())
    54  	}
    55  
    56  	req, err := client.ListSupportedConfigurationsPreparer(ctx, resourceGroupName, managerName)
    57  	if err != nil {
    58  		err = autorest.NewErrorWithError(err, "storsimple.CloudAppliancesClient", "ListSupportedConfigurations", nil, "Failure preparing request")
    59  		return
    60  	}
    61  
    62  	resp, err := client.ListSupportedConfigurationsSender(req)
    63  	if err != nil {
    64  		result.Response = autorest.Response{Response: resp}
    65  		err = autorest.NewErrorWithError(err, "storsimple.CloudAppliancesClient", "ListSupportedConfigurations", resp, "Failure sending request")
    66  		return
    67  	}
    68  
    69  	result, err = client.ListSupportedConfigurationsResponder(resp)
    70  	if err != nil {
    71  		err = autorest.NewErrorWithError(err, "storsimple.CloudAppliancesClient", "ListSupportedConfigurations", resp, "Failure responding to request")
    72  		return
    73  	}
    74  
    75  	return
    76  }
    77  
    78  // ListSupportedConfigurationsPreparer prepares the ListSupportedConfigurations request.
    79  func (client CloudAppliancesClient) ListSupportedConfigurationsPreparer(ctx context.Context, resourceGroupName string, managerName string) (*http.Request, error) {
    80  	pathParameters := map[string]interface{}{
    81  		"managerName":       managerName,
    82  		"resourceGroupName": resourceGroupName,
    83  		"subscriptionId":    client.SubscriptionID,
    84  	}
    85  
    86  	const APIVersion = "2017-06-01"
    87  	queryParameters := map[string]interface{}{
    88  		"api-version": APIVersion,
    89  	}
    90  
    91  	preparer := autorest.CreatePreparer(
    92  		autorest.AsGet(),
    93  		autorest.WithBaseURL(client.BaseURI),
    94  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/cloudApplianceConfigurations", pathParameters),
    95  		autorest.WithQueryParameters(queryParameters))
    96  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    97  }
    98  
    99  // ListSupportedConfigurationsSender sends the ListSupportedConfigurations request. The method will close the
   100  // http.Response Body if it receives an error.
   101  func (client CloudAppliancesClient) ListSupportedConfigurationsSender(req *http.Request) (*http.Response, error) {
   102  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   103  }
   104  
   105  // ListSupportedConfigurationsResponder handles the response to the ListSupportedConfigurations request. The method always
   106  // closes the http.Response Body.
   107  func (client CloudAppliancesClient) ListSupportedConfigurationsResponder(resp *http.Response) (result CloudApplianceConfigurationList, err error) {
   108  	err = autorest.Respond(
   109  		resp,
   110  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   111  		autorest.ByUnmarshallingJSON(&result),
   112  		autorest.ByClosing())
   113  	result.Response = autorest.Response{Response: resp}
   114  	return
   115  }
   116  
   117  // Provision provisions cloud appliance.
   118  // Parameters:
   119  // parameters - the cloud appliance
   120  // resourceGroupName - the resource group name
   121  // managerName - the manager name
   122  func (client CloudAppliancesClient) Provision(ctx context.Context, parameters CloudAppliance, resourceGroupName string, managerName string) (result CloudAppliancesProvisionFuture, err error) {
   123  	if tracing.IsEnabled() {
   124  		ctx = tracing.StartSpan(ctx, fqdn+"/CloudAppliancesClient.Provision")
   125  		defer func() {
   126  			sc := -1
   127  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   128  				sc = result.FutureAPI.Response().StatusCode
   129  			}
   130  			tracing.EndSpan(ctx, sc, err)
   131  		}()
   132  	}
   133  	if err := validation.Validate([]validation.Validation{
   134  		{TargetValue: parameters,
   135  			Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil},
   136  				{Target: "parameters.VnetRegion", Name: validation.Null, Rule: true, Chain: nil}}},
   137  		{TargetValue: managerName,
   138  			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   139  				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
   140  		return result, validation.NewError("storsimple.CloudAppliancesClient", "Provision", err.Error())
   141  	}
   142  
   143  	req, err := client.ProvisionPreparer(ctx, parameters, resourceGroupName, managerName)
   144  	if err != nil {
   145  		err = autorest.NewErrorWithError(err, "storsimple.CloudAppliancesClient", "Provision", nil, "Failure preparing request")
   146  		return
   147  	}
   148  
   149  	result, err = client.ProvisionSender(req)
   150  	if err != nil {
   151  		err = autorest.NewErrorWithError(err, "storsimple.CloudAppliancesClient", "Provision", result.Response(), "Failure sending request")
   152  		return
   153  	}
   154  
   155  	return
   156  }
   157  
   158  // ProvisionPreparer prepares the Provision request.
   159  func (client CloudAppliancesClient) ProvisionPreparer(ctx context.Context, parameters CloudAppliance, resourceGroupName string, managerName string) (*http.Request, error) {
   160  	pathParameters := map[string]interface{}{
   161  		"managerName":       managerName,
   162  		"resourceGroupName": resourceGroupName,
   163  		"subscriptionId":    client.SubscriptionID,
   164  	}
   165  
   166  	const APIVersion = "2017-06-01"
   167  	queryParameters := map[string]interface{}{
   168  		"api-version": APIVersion,
   169  	}
   170  
   171  	preparer := autorest.CreatePreparer(
   172  		autorest.AsContentType("application/json; charset=utf-8"),
   173  		autorest.AsPost(),
   174  		autorest.WithBaseURL(client.BaseURI),
   175  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/provisionCloudAppliance", pathParameters),
   176  		autorest.WithJSON(parameters),
   177  		autorest.WithQueryParameters(queryParameters))
   178  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   179  }
   180  
   181  // ProvisionSender sends the Provision request. The method will close the
   182  // http.Response Body if it receives an error.
   183  func (client CloudAppliancesClient) ProvisionSender(req *http.Request) (future CloudAppliancesProvisionFuture, err error) {
   184  	var resp *http.Response
   185  	future.FutureAPI = &azure.Future{}
   186  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   187  	if err != nil {
   188  		return
   189  	}
   190  	var azf azure.Future
   191  	azf, err = azure.NewFutureFromResponse(resp)
   192  	future.FutureAPI = &azf
   193  	future.Result = future.result
   194  	return
   195  }
   196  
   197  // ProvisionResponder handles the response to the Provision request. The method always
   198  // closes the http.Response Body.
   199  func (client CloudAppliancesClient) ProvisionResponder(resp *http.Response) (result autorest.Response, err error) {
   200  	err = autorest.Respond(
   201  		resp,
   202  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   203  		autorest.ByClosing())
   204  	result.Response = resp
   205  	return
   206  }
   207  

View as plain text