...

Source file src/github.com/Azure/azure-sdk-for-go/services/machinelearning/mgmt/2019-10-01/workspaces/operations.go

Documentation: github.com/Azure/azure-sdk-for-go/services/machinelearning/mgmt/2019-10-01/workspaces

     1  package workspaces
     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 Workspace resources. They
    18  // support CRUD operations for Azure Machine Learning Workspaces.
    19  type OperationsClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewOperationsClient creates an instance of the OperationsClient client.
    24  func NewOperationsClient(subscriptionID string) OperationsClient {
    25  	return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID)
    26  }
    27  
    28  // NewOperationsClientWithBaseURI creates an instance of the OperationsClient 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 NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient {
    31  	return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)}
    32  }
    33  
    34  // List lists all of the available Azure Machine Learning Studio REST API operations.
    35  func (client OperationsClient) List(ctx context.Context) (result OperationListResult, err error) {
    36  	if tracing.IsEnabled() {
    37  		ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List")
    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.ListPreparer(ctx)
    47  	if err != nil {
    48  		err = autorest.NewErrorWithError(err, "workspaces.OperationsClient", "List", nil, "Failure preparing request")
    49  		return
    50  	}
    51  
    52  	resp, err := client.ListSender(req)
    53  	if err != nil {
    54  		result.Response = autorest.Response{Response: resp}
    55  		err = autorest.NewErrorWithError(err, "workspaces.OperationsClient", "List", resp, "Failure sending request")
    56  		return
    57  	}
    58  
    59  	result, err = client.ListResponder(resp)
    60  	if err != nil {
    61  		err = autorest.NewErrorWithError(err, "workspaces.OperationsClient", "List", resp, "Failure responding to request")
    62  		return
    63  	}
    64  
    65  	return
    66  }
    67  
    68  // ListPreparer prepares the List request.
    69  func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) {
    70  	const APIVersion = "2019-10-01"
    71  	queryParameters := map[string]interface{}{
    72  		"api-version": APIVersion,
    73  	}
    74  
    75  	preparer := autorest.CreatePreparer(
    76  		autorest.AsGet(),
    77  		autorest.WithBaseURL(client.BaseURI),
    78  		autorest.WithPath("/providers/Microsoft.MachineLearning/operations"),
    79  		autorest.WithQueryParameters(queryParameters))
    80  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    81  }
    82  
    83  // ListSender sends the List request. The method will close the
    84  // http.Response Body if it receives an error.
    85  func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) {
    86  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
    87  }
    88  
    89  // ListResponder handles the response to the List request. The method always
    90  // closes the http.Response Body.
    91  func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) {
    92  	err = autorest.Respond(
    93  		resp,
    94  		azure.WithErrorUnlessStatusCode(http.StatusOK),
    95  		autorest.ByUnmarshallingJSON(&result),
    96  		autorest.ByClosing())
    97  	result.Response = autorest.Response{Response: resp}
    98  	return
    99  }
   100  

View as plain text