...

Source file src/github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2022-06-01-preview/insights/vminsights.go

Documentation: github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2022-06-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/tracing"
    14  	"net/http"
    15  )
    16  
    17  // VMInsightsClient is the monitor Management Client
    18  type VMInsightsClient struct {
    19  	BaseClient
    20  }
    21  
    22  // NewVMInsightsClient creates an instance of the VMInsightsClient client.
    23  func NewVMInsightsClient(subscriptionID string) VMInsightsClient {
    24  	return NewVMInsightsClientWithBaseURI(DefaultBaseURI, subscriptionID)
    25  }
    26  
    27  // NewVMInsightsClientWithBaseURI creates an instance of the VMInsightsClient client using a custom endpoint.  Use this
    28  // when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
    29  func NewVMInsightsClientWithBaseURI(baseURI string, subscriptionID string) VMInsightsClient {
    30  	return VMInsightsClient{NewWithBaseURI(baseURI, subscriptionID)}
    31  }
    32  
    33  // GetOnboardingStatus retrieves the VM Insights onboarding status for the specified resource or resource scope.
    34  // Parameters:
    35  // resourceURI - the fully qualified Azure Resource manager identifier of the resource, or scope, whose status
    36  // to retrieve.
    37  func (client VMInsightsClient) GetOnboardingStatus(ctx context.Context, resourceURI string) (result VMInsightsOnboardingStatus, err error) {
    38  	if tracing.IsEnabled() {
    39  		ctx = tracing.StartSpan(ctx, fqdn+"/VMInsightsClient.GetOnboardingStatus")
    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.GetOnboardingStatusPreparer(ctx, resourceURI)
    49  	if err != nil {
    50  		err = autorest.NewErrorWithError(err, "insights.VMInsightsClient", "GetOnboardingStatus", nil, "Failure preparing request")
    51  		return
    52  	}
    53  
    54  	resp, err := client.GetOnboardingStatusSender(req)
    55  	if err != nil {
    56  		result.Response = autorest.Response{Response: resp}
    57  		err = autorest.NewErrorWithError(err, "insights.VMInsightsClient", "GetOnboardingStatus", resp, "Failure sending request")
    58  		return
    59  	}
    60  
    61  	result, err = client.GetOnboardingStatusResponder(resp)
    62  	if err != nil {
    63  		err = autorest.NewErrorWithError(err, "insights.VMInsightsClient", "GetOnboardingStatus", resp, "Failure responding to request")
    64  		return
    65  	}
    66  
    67  	return
    68  }
    69  
    70  // GetOnboardingStatusPreparer prepares the GetOnboardingStatus request.
    71  func (client VMInsightsClient) GetOnboardingStatusPreparer(ctx context.Context, resourceURI string) (*http.Request, error) {
    72  	pathParameters := map[string]interface{}{
    73  		"resourceUri": resourceURI,
    74  	}
    75  
    76  	const APIVersion = "2018-11-27-preview"
    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("/{resourceUri}/providers/Microsoft.Insights/vmInsightsOnboardingStatuses/default", pathParameters),
    85  		autorest.WithQueryParameters(queryParameters))
    86  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    87  }
    88  
    89  // GetOnboardingStatusSender sends the GetOnboardingStatus request. The method will close the
    90  // http.Response Body if it receives an error.
    91  func (client VMInsightsClient) GetOnboardingStatusSender(req *http.Request) (*http.Response, error) {
    92  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
    93  }
    94  
    95  // GetOnboardingStatusResponder handles the response to the GetOnboardingStatus request. The method always
    96  // closes the http.Response Body.
    97  func (client VMInsightsClient) GetOnboardingStatusResponder(resp *http.Response) (result VMInsightsOnboardingStatus, 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