...

Source file src/github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2021-09-01-preview/insights/privatelinkscopeoperationstatus.go

Documentation: github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2021-09-01-preview/insights

     1  package insights
     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  // PrivateLinkScopeOperationStatusClient is the monitor Management Client
    19  type PrivateLinkScopeOperationStatusClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewPrivateLinkScopeOperationStatusClient creates an instance of the PrivateLinkScopeOperationStatusClient client.
    24  func NewPrivateLinkScopeOperationStatusClient(subscriptionID string) PrivateLinkScopeOperationStatusClient {
    25  	return NewPrivateLinkScopeOperationStatusClientWithBaseURI(DefaultBaseURI, subscriptionID)
    26  }
    27  
    28  // NewPrivateLinkScopeOperationStatusClientWithBaseURI creates an instance of the PrivateLinkScopeOperationStatusClient
    29  // client using a custom endpoint.  Use this when interacting with an Azure cloud that uses a non-standard base URI
    30  // (sovereign clouds, Azure stack).
    31  func NewPrivateLinkScopeOperationStatusClientWithBaseURI(baseURI string, subscriptionID string) PrivateLinkScopeOperationStatusClient {
    32  	return PrivateLinkScopeOperationStatusClient{NewWithBaseURI(baseURI, subscriptionID)}
    33  }
    34  
    35  // Get get the status of an azure asynchronous operation associated with a private link scope operation.
    36  // Parameters:
    37  // asyncOperationID - the operation Id.
    38  // resourceGroupName - the name of the resource group. The name is case insensitive.
    39  func (client PrivateLinkScopeOperationStatusClient) Get(ctx context.Context, asyncOperationID string, resourceGroupName string) (result OperationStatus, err error) {
    40  	if tracing.IsEnabled() {
    41  		ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkScopeOperationStatusClient.Get")
    42  		defer func() {
    43  			sc := -1
    44  			if result.Response.Response != nil {
    45  				sc = result.Response.Response.StatusCode
    46  			}
    47  			tracing.EndSpan(ctx, sc, err)
    48  		}()
    49  	}
    50  	if err := validation.Validate([]validation.Validation{
    51  		{TargetValue: resourceGroupName,
    52  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
    53  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
    54  		{TargetValue: client.SubscriptionID,
    55  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
    56  		return result, validation.NewError("insights.PrivateLinkScopeOperationStatusClient", "Get", err.Error())
    57  	}
    58  
    59  	req, err := client.GetPreparer(ctx, asyncOperationID, resourceGroupName)
    60  	if err != nil {
    61  		err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopeOperationStatusClient", "Get", nil, "Failure preparing request")
    62  		return
    63  	}
    64  
    65  	resp, err := client.GetSender(req)
    66  	if err != nil {
    67  		result.Response = autorest.Response{Response: resp}
    68  		err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopeOperationStatusClient", "Get", resp, "Failure sending request")
    69  		return
    70  	}
    71  
    72  	result, err = client.GetResponder(resp)
    73  	if err != nil {
    74  		err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopeOperationStatusClient", "Get", resp, "Failure responding to request")
    75  		return
    76  	}
    77  
    78  	return
    79  }
    80  
    81  // GetPreparer prepares the Get request.
    82  func (client PrivateLinkScopeOperationStatusClient) GetPreparer(ctx context.Context, asyncOperationID string, resourceGroupName string) (*http.Request, error) {
    83  	pathParameters := map[string]interface{}{
    84  		"asyncOperationId":  autorest.Encode("path", asyncOperationID),
    85  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
    86  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
    87  	}
    88  
    89  	const APIVersion = "2019-10-17-preview"
    90  	queryParameters := map[string]interface{}{
    91  		"api-version": APIVersion,
    92  	}
    93  
    94  	preparer := autorest.CreatePreparer(
    95  		autorest.AsGet(),
    96  		autorest.WithBaseURL(client.BaseURI),
    97  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopeOperationStatuses/{asyncOperationId}", pathParameters),
    98  		autorest.WithQueryParameters(queryParameters))
    99  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   100  }
   101  
   102  // GetSender sends the Get request. The method will close the
   103  // http.Response Body if it receives an error.
   104  func (client PrivateLinkScopeOperationStatusClient) GetSender(req *http.Request) (*http.Response, error) {
   105  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   106  }
   107  
   108  // GetResponder handles the response to the Get request. The method always
   109  // closes the http.Response Body.
   110  func (client PrivateLinkScopeOperationStatusClient) GetResponder(resp *http.Response) (result OperationStatus, err error) {
   111  	err = autorest.Respond(
   112  		resp,
   113  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   114  		autorest.ByUnmarshallingJSON(&result),
   115  		autorest.ByClosing())
   116  	result.Response = autorest.Response{Response: resp}
   117  	return
   118  }
   119  

View as plain text