...

Source file src/github.com/Azure/azure-sdk-for-go/services/appinsights/mgmt/2015-05-01/insights/componentfeaturecapabilities.go

Documentation: github.com/Azure/azure-sdk-for-go/services/appinsights/mgmt/2015-05-01/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  // ComponentFeatureCapabilitiesClient is the composite Swagger for Application Insights Management Client
    19  type ComponentFeatureCapabilitiesClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewComponentFeatureCapabilitiesClient creates an instance of the ComponentFeatureCapabilitiesClient client.
    24  func NewComponentFeatureCapabilitiesClient(subscriptionID string) ComponentFeatureCapabilitiesClient {
    25  	return NewComponentFeatureCapabilitiesClientWithBaseURI(DefaultBaseURI, subscriptionID)
    26  }
    27  
    28  // NewComponentFeatureCapabilitiesClientWithBaseURI creates an instance of the ComponentFeatureCapabilitiesClient
    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 NewComponentFeatureCapabilitiesClientWithBaseURI(baseURI string, subscriptionID string) ComponentFeatureCapabilitiesClient {
    32  	return ComponentFeatureCapabilitiesClient{NewWithBaseURI(baseURI, subscriptionID)}
    33  }
    34  
    35  // Get returns feature capabilities of the application insights component.
    36  // Parameters:
    37  // resourceGroupName - the name of the resource group. The name is case insensitive.
    38  // resourceName - the name of the Application Insights component resource.
    39  func (client ComponentFeatureCapabilitiesClient) Get(ctx context.Context, resourceGroupName string, resourceName string) (result ApplicationInsightsComponentFeatureCapabilities, err error) {
    40  	if tracing.IsEnabled() {
    41  		ctx = tracing.StartSpan(ctx, fqdn+"/ComponentFeatureCapabilitiesClient.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  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
    55  		{TargetValue: client.SubscriptionID,
    56  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
    57  		return result, validation.NewError("insights.ComponentFeatureCapabilitiesClient", "Get", err.Error())
    58  	}
    59  
    60  	req, err := client.GetPreparer(ctx, resourceGroupName, resourceName)
    61  	if err != nil {
    62  		err = autorest.NewErrorWithError(err, "insights.ComponentFeatureCapabilitiesClient", "Get", nil, "Failure preparing request")
    63  		return
    64  	}
    65  
    66  	resp, err := client.GetSender(req)
    67  	if err != nil {
    68  		result.Response = autorest.Response{Response: resp}
    69  		err = autorest.NewErrorWithError(err, "insights.ComponentFeatureCapabilitiesClient", "Get", resp, "Failure sending request")
    70  		return
    71  	}
    72  
    73  	result, err = client.GetResponder(resp)
    74  	if err != nil {
    75  		err = autorest.NewErrorWithError(err, "insights.ComponentFeatureCapabilitiesClient", "Get", resp, "Failure responding to request")
    76  		return
    77  	}
    78  
    79  	return
    80  }
    81  
    82  // GetPreparer prepares the Get request.
    83  func (client ComponentFeatureCapabilitiesClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) {
    84  	pathParameters := map[string]interface{}{
    85  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
    86  		"resourceName":      autorest.Encode("path", resourceName),
    87  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
    88  	}
    89  
    90  	const APIVersion = "2015-05-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.Insights/components/{resourceName}/featurecapabilities", pathParameters),
    99  		autorest.WithQueryParameters(queryParameters))
   100  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   101  }
   102  
   103  // GetSender sends the Get request. The method will close the
   104  // http.Response Body if it receives an error.
   105  func (client ComponentFeatureCapabilitiesClient) GetSender(req *http.Request) (*http.Response, error) {
   106  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   107  }
   108  
   109  // GetResponder handles the response to the Get request. The method always
   110  // closes the http.Response Body.
   111  func (client ComponentFeatureCapabilitiesClient) GetResponder(resp *http.Response) (result ApplicationInsightsComponentFeatureCapabilities, 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