...

Source file src/github.com/Azure/azure-sdk-for-go/services/machinelearning/mgmt/2017-01-01/webservices/operations.go

Documentation: github.com/Azure/azure-sdk-for-go/services/machinelearning/mgmt/2017-01-01/webservices

     1  package webservices
     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  // OperationsClient is the these APIs allow end users to operate on Azure Machine Learning Web Services resources. They
    18  // support the following operations:<ul><li>Create or update a web service</li><li>Get a web service</li><li>Patch a
    19  // web service</li><li>Delete a web service</li><li>Get All Web Services in a Resource Group </li><li>Get All Web
    20  // Services in a Subscription</li><li>Get Web Services Keys</li></ul>
    21  type OperationsClient struct {
    22  	BaseClient
    23  }
    24  
    25  // NewOperationsClient creates an instance of the OperationsClient client.
    26  func NewOperationsClient(subscriptionID string) OperationsClient {
    27  	return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID)
    28  }
    29  
    30  // NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint.  Use this
    31  // when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
    32  func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient {
    33  	return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)}
    34  }
    35  
    36  // List lists all the available REST API operations.
    37  func (client OperationsClient) List(ctx context.Context) (result OperationEntityListResult, err error) {
    38  	if tracing.IsEnabled() {
    39  		ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List")
    40  		defer func() {
    41  			sc := -1
    42  			if result.Response.Response != nil {
    43  				sc = result.Response.Response.StatusCode
    44  			}
    45  			tracing.EndSpan(ctx, sc, err)
    46  		}()
    47  	}
    48  	req, err := client.ListPreparer(ctx)
    49  	if err != nil {
    50  		err = autorest.NewErrorWithError(err, "webservices.OperationsClient", "List", nil, "Failure preparing request")
    51  		return
    52  	}
    53  
    54  	resp, err := client.ListSender(req)
    55  	if err != nil {
    56  		result.Response = autorest.Response{Response: resp}
    57  		err = autorest.NewErrorWithError(err, "webservices.OperationsClient", "List", resp, "Failure sending request")
    58  		return
    59  	}
    60  
    61  	result, err = client.ListResponder(resp)
    62  	if err != nil {
    63  		err = autorest.NewErrorWithError(err, "webservices.OperationsClient", "List", resp, "Failure responding to request")
    64  		return
    65  	}
    66  
    67  	return
    68  }
    69  
    70  // ListPreparer prepares the List request.
    71  func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) {
    72  	const APIVersion = "2017-01-01"
    73  	queryParameters := map[string]interface{}{
    74  		"api-version": APIVersion,
    75  	}
    76  
    77  	preparer := autorest.CreatePreparer(
    78  		autorest.AsGet(),
    79  		autorest.WithBaseURL(client.BaseURI),
    80  		autorest.WithPath("/providers/Microsoft.MachineLearning/operations"),
    81  		autorest.WithQueryParameters(queryParameters))
    82  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    83  }
    84  
    85  // ListSender sends the List request. The method will close the
    86  // http.Response Body if it receives an error.
    87  func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) {
    88  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
    89  }
    90  
    91  // ListResponder handles the response to the List request. The method always
    92  // closes the http.Response Body.
    93  func (client OperationsClient) ListResponder(resp *http.Response) (result OperationEntityListResult, err error) {
    94  	err = autorest.Respond(
    95  		resp,
    96  		azure.WithErrorUnlessStatusCode(http.StatusOK),
    97  		autorest.ByUnmarshallingJSON(&result),
    98  		autorest.ByClosing())
    99  	result.Response = autorest.Response{Response: resp}
   100  	return
   101  }
   102  

View as plain text