...

Source file src/github.com/Azure/azure-sdk-for-go/services/machinelearningservices/mgmt/2021-07-01/machinelearningservices/privatelinkresources.go

Documentation: github.com/Azure/azure-sdk-for-go/services/machinelearningservices/mgmt/2021-07-01/machinelearningservices

     1  package machinelearningservices
     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  // PrivateLinkResourcesClient is the these APIs allow end users to operate on Azure Machine Learning Workspace
    19  // resources.
    20  type PrivateLinkResourcesClient struct {
    21  	BaseClient
    22  }
    23  
    24  // NewPrivateLinkResourcesClient creates an instance of the PrivateLinkResourcesClient client.
    25  func NewPrivateLinkResourcesClient(subscriptionID string) PrivateLinkResourcesClient {
    26  	return NewPrivateLinkResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID)
    27  }
    28  
    29  // NewPrivateLinkResourcesClientWithBaseURI creates an instance of the PrivateLinkResourcesClient client using a custom
    30  // endpoint.  Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure
    31  // stack).
    32  func NewPrivateLinkResourcesClientWithBaseURI(baseURI string, subscriptionID string) PrivateLinkResourcesClient {
    33  	return PrivateLinkResourcesClient{NewWithBaseURI(baseURI, subscriptionID)}
    34  }
    35  
    36  // List gets the private link resources that need to be created for a workspace.
    37  // Parameters:
    38  // resourceGroupName - the name of the resource group. The name is case insensitive.
    39  // workspaceName - name of Azure Machine Learning workspace.
    40  func (client PrivateLinkResourcesClient) List(ctx context.Context, resourceGroupName string, workspaceName string) (result PrivateLinkResourceListResult, err error) {
    41  	if tracing.IsEnabled() {
    42  		ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.List")
    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  	if err := validation.Validate([]validation.Validation{
    52  		{TargetValue: client.SubscriptionID,
    53  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
    54  		{TargetValue: resourceGroupName,
    55  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
    56  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
    57  		return result, validation.NewError("machinelearningservices.PrivateLinkResourcesClient", "List", err.Error())
    58  	}
    59  
    60  	req, err := client.ListPreparer(ctx, resourceGroupName, workspaceName)
    61  	if err != nil {
    62  		err = autorest.NewErrorWithError(err, "machinelearningservices.PrivateLinkResourcesClient", "List", nil, "Failure preparing request")
    63  		return
    64  	}
    65  
    66  	resp, err := client.ListSender(req)
    67  	if err != nil {
    68  		result.Response = autorest.Response{Response: resp}
    69  		err = autorest.NewErrorWithError(err, "machinelearningservices.PrivateLinkResourcesClient", "List", resp, "Failure sending request")
    70  		return
    71  	}
    72  
    73  	result, err = client.ListResponder(resp)
    74  	if err != nil {
    75  		err = autorest.NewErrorWithError(err, "machinelearningservices.PrivateLinkResourcesClient", "List", resp, "Failure responding to request")
    76  		return
    77  	}
    78  
    79  	return
    80  }
    81  
    82  // ListPreparer prepares the List request.
    83  func (client PrivateLinkResourcesClient) ListPreparer(ctx context.Context, resourceGroupName string, workspaceName string) (*http.Request, error) {
    84  	pathParameters := map[string]interface{}{
    85  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
    86  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
    87  		"workspaceName":     autorest.Encode("path", workspaceName),
    88  	}
    89  
    90  	const APIVersion = "2021-07-01"
    91  	queryParameters := map[string]interface{}{
    92  		"api-version": APIVersion,
    93  	}
    94  
    95  	preparer := autorest.CreatePreparer(
    96  		autorest.AsGet(),
    97  		autorest.WithBaseURL(client.BaseURI),
    98  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/privateLinkResources", pathParameters),
    99  		autorest.WithQueryParameters(queryParameters))
   100  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   101  }
   102  
   103  // ListSender sends the List request. The method will close the
   104  // http.Response Body if it receives an error.
   105  func (client PrivateLinkResourcesClient) ListSender(req *http.Request) (*http.Response, error) {
   106  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   107  }
   108  
   109  // ListResponder handles the response to the List request. The method always
   110  // closes the http.Response Body.
   111  func (client PrivateLinkResourcesClient) ListResponder(resp *http.Response) (result PrivateLinkResourceListResult, err error) {
   112  	err = autorest.Respond(
   113  		resp,
   114  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   115  		autorest.ByUnmarshallingJSON(&result),
   116  		autorest.ByClosing())
   117  	result.Response = autorest.Response{Response: resp}
   118  	return
   119  }
   120  

View as plain text