...

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

Documentation: github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2018-07-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  // SupportedOperatingSystemsClient is the client for the SupportedOperatingSystems methods of the Siterecovery service.
    18  type SupportedOperatingSystemsClient struct {
    19  	BaseClient
    20  }
    21  
    22  // NewSupportedOperatingSystemsClient creates an instance of the SupportedOperatingSystemsClient client.
    23  func NewSupportedOperatingSystemsClient(subscriptionID string, resourceGroupName string, resourceName string) SupportedOperatingSystemsClient {
    24  	return NewSupportedOperatingSystemsClientWithBaseURI(DefaultBaseURI, subscriptionID, resourceGroupName, resourceName)
    25  }
    26  
    27  // NewSupportedOperatingSystemsClientWithBaseURI creates an instance of the SupportedOperatingSystemsClient client
    28  // using a custom endpoint.  Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign
    29  // clouds, Azure stack).
    30  func NewSupportedOperatingSystemsClientWithBaseURI(baseURI string, subscriptionID string, resourceGroupName string, resourceName string) SupportedOperatingSystemsClient {
    31  	return SupportedOperatingSystemsClient{NewWithBaseURI(baseURI, subscriptionID, resourceGroupName, resourceName)}
    32  }
    33  
    34  // Get sends the get request.
    35  func (client SupportedOperatingSystemsClient) Get(ctx context.Context) (result SupportedOperatingSystems, err error) {
    36  	if tracing.IsEnabled() {
    37  		ctx = tracing.StartSpan(ctx, fqdn+"/SupportedOperatingSystemsClient.Get")
    38  		defer func() {
    39  			sc := -1
    40  			if result.Response.Response != nil {
    41  				sc = result.Response.Response.StatusCode
    42  			}
    43  			tracing.EndSpan(ctx, sc, err)
    44  		}()
    45  	}
    46  	req, err := client.GetPreparer(ctx)
    47  	if err != nil {
    48  		err = autorest.NewErrorWithError(err, "siterecovery.SupportedOperatingSystemsClient", "Get", nil, "Failure preparing request")
    49  		return
    50  	}
    51  
    52  	resp, err := client.GetSender(req)
    53  	if err != nil {
    54  		result.Response = autorest.Response{Response: resp}
    55  		err = autorest.NewErrorWithError(err, "siterecovery.SupportedOperatingSystemsClient", "Get", resp, "Failure sending request")
    56  		return
    57  	}
    58  
    59  	result, err = client.GetResponder(resp)
    60  	if err != nil {
    61  		err = autorest.NewErrorWithError(err, "siterecovery.SupportedOperatingSystemsClient", "Get", resp, "Failure responding to request")
    62  		return
    63  	}
    64  
    65  	return
    66  }
    67  
    68  // GetPreparer prepares the Get request.
    69  func (client SupportedOperatingSystemsClient) GetPreparer(ctx context.Context) (*http.Request, error) {
    70  	pathParameters := map[string]interface{}{
    71  		"resourceGroupName": autorest.Encode("path", client.ResourceGroupName),
    72  		"resourceName":      autorest.Encode("path", client.ResourceName),
    73  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
    74  	}
    75  
    76  	const APIVersion = "2018-07-10"
    77  	queryParameters := map[string]interface{}{
    78  		"api-version": APIVersion,
    79  	}
    80  
    81  	preparer := autorest.CreatePreparer(
    82  		autorest.AsGet(),
    83  		autorest.WithBaseURL(client.BaseURI),
    84  		autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationSupportedOperatingSystems", pathParameters),
    85  		autorest.WithQueryParameters(queryParameters))
    86  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    87  }
    88  
    89  // GetSender sends the Get request. The method will close the
    90  // http.Response Body if it receives an error.
    91  func (client SupportedOperatingSystemsClient) GetSender(req *http.Request) (*http.Response, error) {
    92  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
    93  }
    94  
    95  // GetResponder handles the response to the Get request. The method always
    96  // closes the http.Response Body.
    97  func (client SupportedOperatingSystemsClient) GetResponder(resp *http.Response) (result SupportedOperatingSystems, err error) {
    98  	err = autorest.Respond(
    99  		resp,
   100  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   101  		autorest.ByUnmarshallingJSON(&result),
   102  		autorest.ByClosing())
   103  	result.Response = autorest.Response{Response: resp}
   104  	return
   105  }
   106  

View as plain text