...

Source file src/github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2018-01-10/siterecovery/replicationstorageclassifications.go

Documentation: github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2018-01-10/siterecovery

     1  package siterecovery
     2  
     3  // Copyright (c) Microsoft Corporation. All rights reserved.
     4  // Licensed under the MIT License. See License.txt in the project root for license information.
     5  //
     6  // Code generated by Microsoft (R) AutoRest Code Generator.
     7  // Changes may cause incorrect behavior and will be lost if the code is regenerated.
     8  
     9  import (
    10  	"context"
    11  	"github.com/Azure/go-autorest/autorest"
    12  	"github.com/Azure/go-autorest/autorest/azure"
    13  	"github.com/Azure/go-autorest/tracing"
    14  	"net/http"
    15  )
    16  
    17  // ReplicationStorageClassificationsClient is the client for the ReplicationStorageClassifications methods of the
    18  // Siterecovery service.
    19  type ReplicationStorageClassificationsClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewReplicationStorageClassificationsClient creates an instance of the ReplicationStorageClassificationsClient
    24  // client.
    25  func NewReplicationStorageClassificationsClient(subscriptionID string, resourceGroupName string, resourceName string) ReplicationStorageClassificationsClient {
    26  	return NewReplicationStorageClassificationsClientWithBaseURI(DefaultBaseURI, subscriptionID, resourceGroupName, resourceName)
    27  }
    28  
    29  // NewReplicationStorageClassificationsClientWithBaseURI creates an instance of the
    30  // ReplicationStorageClassificationsClient client using a custom endpoint.  Use this when interacting with an Azure
    31  // cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
    32  func NewReplicationStorageClassificationsClientWithBaseURI(baseURI string, subscriptionID string, resourceGroupName string, resourceName string) ReplicationStorageClassificationsClient {
    33  	return ReplicationStorageClassificationsClient{NewWithBaseURI(baseURI, subscriptionID, resourceGroupName, resourceName)}
    34  }
    35  
    36  // Get gets the details of the specified storage classification.
    37  // Parameters:
    38  // fabricName - fabric name.
    39  // storageClassificationName - storage classification name.
    40  func (client ReplicationStorageClassificationsClient) Get(ctx context.Context, fabricName string, storageClassificationName string) (result StorageClassification, err error) {
    41  	if tracing.IsEnabled() {
    42  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationStorageClassificationsClient.Get")
    43  		defer func() {
    44  			sc := -1
    45  			if result.Response.Response != nil {
    46  				sc = result.Response.Response.StatusCode
    47  			}
    48  			tracing.EndSpan(ctx, sc, err)
    49  		}()
    50  	}
    51  	req, err := client.GetPreparer(ctx, fabricName, storageClassificationName)
    52  	if err != nil {
    53  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationStorageClassificationsClient", "Get", nil, "Failure preparing request")
    54  		return
    55  	}
    56  
    57  	resp, err := client.GetSender(req)
    58  	if err != nil {
    59  		result.Response = autorest.Response{Response: resp}
    60  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationStorageClassificationsClient", "Get", resp, "Failure sending request")
    61  		return
    62  	}
    63  
    64  	result, err = client.GetResponder(resp)
    65  	if err != nil {
    66  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationStorageClassificationsClient", "Get", resp, "Failure responding to request")
    67  		return
    68  	}
    69  
    70  	return
    71  }
    72  
    73  // GetPreparer prepares the Get request.
    74  func (client ReplicationStorageClassificationsClient) GetPreparer(ctx context.Context, fabricName string, storageClassificationName string) (*http.Request, error) {
    75  	pathParameters := map[string]interface{}{
    76  		"fabricName":                autorest.Encode("path", fabricName),
    77  		"resourceGroupName":         autorest.Encode("path", client.ResourceGroupName),
    78  		"resourceName":              autorest.Encode("path", client.ResourceName),
    79  		"storageClassificationName": autorest.Encode("path", storageClassificationName),
    80  		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
    81  	}
    82  
    83  	const APIVersion = "2018-01-10"
    84  	queryParameters := map[string]interface{}{
    85  		"api-version": APIVersion,
    86  	}
    87  
    88  	preparer := autorest.CreatePreparer(
    89  		autorest.AsGet(),
    90  		autorest.WithBaseURL(client.BaseURI),
    91  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationStorageClassifications/{storageClassificationName}", pathParameters),
    92  		autorest.WithQueryParameters(queryParameters))
    93  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    94  }
    95  
    96  // GetSender sends the Get request. The method will close the
    97  // http.Response Body if it receives an error.
    98  func (client ReplicationStorageClassificationsClient) GetSender(req *http.Request) (*http.Response, error) {
    99  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   100  }
   101  
   102  // GetResponder handles the response to the Get request. The method always
   103  // closes the http.Response Body.
   104  func (client ReplicationStorageClassificationsClient) GetResponder(resp *http.Response) (result StorageClassification, err error) {
   105  	err = autorest.Respond(
   106  		resp,
   107  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   108  		autorest.ByUnmarshallingJSON(&result),
   109  		autorest.ByClosing())
   110  	result.Response = autorest.Response{Response: resp}
   111  	return
   112  }
   113  
   114  // List lists the storage classifications in the vault.
   115  func (client ReplicationStorageClassificationsClient) List(ctx context.Context) (result StorageClassificationCollectionPage, err error) {
   116  	if tracing.IsEnabled() {
   117  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationStorageClassificationsClient.List")
   118  		defer func() {
   119  			sc := -1
   120  			if result.scc.Response.Response != nil {
   121  				sc = result.scc.Response.Response.StatusCode
   122  			}
   123  			tracing.EndSpan(ctx, sc, err)
   124  		}()
   125  	}
   126  	result.fn = client.listNextResults
   127  	req, err := client.ListPreparer(ctx)
   128  	if err != nil {
   129  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationStorageClassificationsClient", "List", nil, "Failure preparing request")
   130  		return
   131  	}
   132  
   133  	resp, err := client.ListSender(req)
   134  	if err != nil {
   135  		result.scc.Response = autorest.Response{Response: resp}
   136  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationStorageClassificationsClient", "List", resp, "Failure sending request")
   137  		return
   138  	}
   139  
   140  	result.scc, err = client.ListResponder(resp)
   141  	if err != nil {
   142  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationStorageClassificationsClient", "List", resp, "Failure responding to request")
   143  		return
   144  	}
   145  	if result.scc.hasNextLink() && result.scc.IsEmpty() {
   146  		err = result.NextWithContext(ctx)
   147  		return
   148  	}
   149  
   150  	return
   151  }
   152  
   153  // ListPreparer prepares the List request.
   154  func (client ReplicationStorageClassificationsClient) ListPreparer(ctx context.Context) (*http.Request, error) {
   155  	pathParameters := map[string]interface{}{
   156  		"resourceGroupName": autorest.Encode("path", client.ResourceGroupName),
   157  		"resourceName":      autorest.Encode("path", client.ResourceName),
   158  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   159  	}
   160  
   161  	const APIVersion = "2018-01-10"
   162  	queryParameters := map[string]interface{}{
   163  		"api-version": APIVersion,
   164  	}
   165  
   166  	preparer := autorest.CreatePreparer(
   167  		autorest.AsGet(),
   168  		autorest.WithBaseURL(client.BaseURI),
   169  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationStorageClassifications", pathParameters),
   170  		autorest.WithQueryParameters(queryParameters))
   171  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   172  }
   173  
   174  // ListSender sends the List request. The method will close the
   175  // http.Response Body if it receives an error.
   176  func (client ReplicationStorageClassificationsClient) ListSender(req *http.Request) (*http.Response, error) {
   177  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   178  }
   179  
   180  // ListResponder handles the response to the List request. The method always
   181  // closes the http.Response Body.
   182  func (client ReplicationStorageClassificationsClient) ListResponder(resp *http.Response) (result StorageClassificationCollection, err error) {
   183  	err = autorest.Respond(
   184  		resp,
   185  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   186  		autorest.ByUnmarshallingJSON(&result),
   187  		autorest.ByClosing())
   188  	result.Response = autorest.Response{Response: resp}
   189  	return
   190  }
   191  
   192  // listNextResults retrieves the next set of results, if any.
   193  func (client ReplicationStorageClassificationsClient) listNextResults(ctx context.Context, lastResults StorageClassificationCollection) (result StorageClassificationCollection, err error) {
   194  	req, err := lastResults.storageClassificationCollectionPreparer(ctx)
   195  	if err != nil {
   196  		return result, autorest.NewErrorWithError(err, "siterecovery.ReplicationStorageClassificationsClient", "listNextResults", nil, "Failure preparing next results request")
   197  	}
   198  	if req == nil {
   199  		return
   200  	}
   201  	resp, err := client.ListSender(req)
   202  	if err != nil {
   203  		result.Response = autorest.Response{Response: resp}
   204  		return result, autorest.NewErrorWithError(err, "siterecovery.ReplicationStorageClassificationsClient", "listNextResults", resp, "Failure sending next results request")
   205  	}
   206  	result, err = client.ListResponder(resp)
   207  	if err != nil {
   208  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationStorageClassificationsClient", "listNextResults", resp, "Failure responding to next results request")
   209  	}
   210  	return
   211  }
   212  
   213  // ListComplete enumerates all values, automatically crossing page boundaries as required.
   214  func (client ReplicationStorageClassificationsClient) ListComplete(ctx context.Context) (result StorageClassificationCollectionIterator, err error) {
   215  	if tracing.IsEnabled() {
   216  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationStorageClassificationsClient.List")
   217  		defer func() {
   218  			sc := -1
   219  			if result.Response().Response.Response != nil {
   220  				sc = result.page.Response().Response.Response.StatusCode
   221  			}
   222  			tracing.EndSpan(ctx, sc, err)
   223  		}()
   224  	}
   225  	result.page, err = client.List(ctx)
   226  	return
   227  }
   228  
   229  // ListByReplicationFabrics lists the storage classifications available in the specified fabric.
   230  // Parameters:
   231  // fabricName - site name of interest.
   232  func (client ReplicationStorageClassificationsClient) ListByReplicationFabrics(ctx context.Context, fabricName string) (result StorageClassificationCollectionPage, err error) {
   233  	if tracing.IsEnabled() {
   234  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationStorageClassificationsClient.ListByReplicationFabrics")
   235  		defer func() {
   236  			sc := -1
   237  			if result.scc.Response.Response != nil {
   238  				sc = result.scc.Response.Response.StatusCode
   239  			}
   240  			tracing.EndSpan(ctx, sc, err)
   241  		}()
   242  	}
   243  	result.fn = client.listByReplicationFabricsNextResults
   244  	req, err := client.ListByReplicationFabricsPreparer(ctx, fabricName)
   245  	if err != nil {
   246  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationStorageClassificationsClient", "ListByReplicationFabrics", nil, "Failure preparing request")
   247  		return
   248  	}
   249  
   250  	resp, err := client.ListByReplicationFabricsSender(req)
   251  	if err != nil {
   252  		result.scc.Response = autorest.Response{Response: resp}
   253  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationStorageClassificationsClient", "ListByReplicationFabrics", resp, "Failure sending request")
   254  		return
   255  	}
   256  
   257  	result.scc, err = client.ListByReplicationFabricsResponder(resp)
   258  	if err != nil {
   259  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationStorageClassificationsClient", "ListByReplicationFabrics", resp, "Failure responding to request")
   260  		return
   261  	}
   262  	if result.scc.hasNextLink() && result.scc.IsEmpty() {
   263  		err = result.NextWithContext(ctx)
   264  		return
   265  	}
   266  
   267  	return
   268  }
   269  
   270  // ListByReplicationFabricsPreparer prepares the ListByReplicationFabrics request.
   271  func (client ReplicationStorageClassificationsClient) ListByReplicationFabricsPreparer(ctx context.Context, fabricName string) (*http.Request, error) {
   272  	pathParameters := map[string]interface{}{
   273  		"fabricName":        autorest.Encode("path", fabricName),
   274  		"resourceGroupName": autorest.Encode("path", client.ResourceGroupName),
   275  		"resourceName":      autorest.Encode("path", client.ResourceName),
   276  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   277  	}
   278  
   279  	const APIVersion = "2018-01-10"
   280  	queryParameters := map[string]interface{}{
   281  		"api-version": APIVersion,
   282  	}
   283  
   284  	preparer := autorest.CreatePreparer(
   285  		autorest.AsGet(),
   286  		autorest.WithBaseURL(client.BaseURI),
   287  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationStorageClassifications", pathParameters),
   288  		autorest.WithQueryParameters(queryParameters))
   289  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   290  }
   291  
   292  // ListByReplicationFabricsSender sends the ListByReplicationFabrics request. The method will close the
   293  // http.Response Body if it receives an error.
   294  func (client ReplicationStorageClassificationsClient) ListByReplicationFabricsSender(req *http.Request) (*http.Response, error) {
   295  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   296  }
   297  
   298  // ListByReplicationFabricsResponder handles the response to the ListByReplicationFabrics request. The method always
   299  // closes the http.Response Body.
   300  func (client ReplicationStorageClassificationsClient) ListByReplicationFabricsResponder(resp *http.Response) (result StorageClassificationCollection, err error) {
   301  	err = autorest.Respond(
   302  		resp,
   303  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   304  		autorest.ByUnmarshallingJSON(&result),
   305  		autorest.ByClosing())
   306  	result.Response = autorest.Response{Response: resp}
   307  	return
   308  }
   309  
   310  // listByReplicationFabricsNextResults retrieves the next set of results, if any.
   311  func (client ReplicationStorageClassificationsClient) listByReplicationFabricsNextResults(ctx context.Context, lastResults StorageClassificationCollection) (result StorageClassificationCollection, err error) {
   312  	req, err := lastResults.storageClassificationCollectionPreparer(ctx)
   313  	if err != nil {
   314  		return result, autorest.NewErrorWithError(err, "siterecovery.ReplicationStorageClassificationsClient", "listByReplicationFabricsNextResults", nil, "Failure preparing next results request")
   315  	}
   316  	if req == nil {
   317  		return
   318  	}
   319  	resp, err := client.ListByReplicationFabricsSender(req)
   320  	if err != nil {
   321  		result.Response = autorest.Response{Response: resp}
   322  		return result, autorest.NewErrorWithError(err, "siterecovery.ReplicationStorageClassificationsClient", "listByReplicationFabricsNextResults", resp, "Failure sending next results request")
   323  	}
   324  	result, err = client.ListByReplicationFabricsResponder(resp)
   325  	if err != nil {
   326  		err = autorest.NewErrorWithError(err, "siterecovery.ReplicationStorageClassificationsClient", "listByReplicationFabricsNextResults", resp, "Failure responding to next results request")
   327  	}
   328  	return
   329  }
   330  
   331  // ListByReplicationFabricsComplete enumerates all values, automatically crossing page boundaries as required.
   332  func (client ReplicationStorageClassificationsClient) ListByReplicationFabricsComplete(ctx context.Context, fabricName string) (result StorageClassificationCollectionIterator, err error) {
   333  	if tracing.IsEnabled() {
   334  		ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationStorageClassificationsClient.ListByReplicationFabrics")
   335  		defer func() {
   336  			sc := -1
   337  			if result.Response().Response.Response != nil {
   338  				sc = result.page.Response().Response.Response.StatusCode
   339  			}
   340  			tracing.EndSpan(ctx, sc, err)
   341  		}()
   342  	}
   343  	result.page, err = client.ListByReplicationFabrics(ctx, fabricName)
   344  	return
   345  }
   346  

View as plain text