...

Source file src/github.com/Azure/azure-sdk-for-go/services/appinsights/mgmt/2020-02-02/insights/componentcurrentbillingfeatures.go

Documentation: github.com/Azure/azure-sdk-for-go/services/appinsights/mgmt/2020-02-02/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  // ComponentCurrentBillingFeaturesClient is the composite Swagger for Application Insights Management Client
    19  type ComponentCurrentBillingFeaturesClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewComponentCurrentBillingFeaturesClient creates an instance of the ComponentCurrentBillingFeaturesClient client.
    24  func NewComponentCurrentBillingFeaturesClient(subscriptionID string) ComponentCurrentBillingFeaturesClient {
    25  	return NewComponentCurrentBillingFeaturesClientWithBaseURI(DefaultBaseURI, subscriptionID)
    26  }
    27  
    28  // NewComponentCurrentBillingFeaturesClientWithBaseURI creates an instance of the ComponentCurrentBillingFeaturesClient
    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 NewComponentCurrentBillingFeaturesClientWithBaseURI(baseURI string, subscriptionID string) ComponentCurrentBillingFeaturesClient {
    32  	return ComponentCurrentBillingFeaturesClient{NewWithBaseURI(baseURI, subscriptionID)}
    33  }
    34  
    35  // Get returns current billing features for an 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 ComponentCurrentBillingFeaturesClient) Get(ctx context.Context, resourceGroupName string, resourceName string) (result ApplicationInsightsComponentBillingFeatures, err error) {
    40  	if tracing.IsEnabled() {
    41  		ctx = tracing.StartSpan(ctx, fqdn+"/ComponentCurrentBillingFeaturesClient.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.ComponentCurrentBillingFeaturesClient", "Get", err.Error())
    57  	}
    58  
    59  	req, err := client.GetPreparer(ctx, resourceGroupName, resourceName)
    60  	if err != nil {
    61  		err = autorest.NewErrorWithError(err, "insights.ComponentCurrentBillingFeaturesClient", "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.ComponentCurrentBillingFeaturesClient", "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.ComponentCurrentBillingFeaturesClient", "Get", resp, "Failure responding to request")
    75  		return
    76  	}
    77  
    78  	return
    79  }
    80  
    81  // GetPreparer prepares the Get request.
    82  func (client ComponentCurrentBillingFeaturesClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) {
    83  	pathParameters := map[string]interface{}{
    84  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
    85  		"resourceName":      autorest.Encode("path", resourceName),
    86  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
    87  	}
    88  
    89  	const APIVersion = "2015-05-01"
    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/components/{resourceName}/currentbillingfeatures", 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 ComponentCurrentBillingFeaturesClient) 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 ComponentCurrentBillingFeaturesClient) GetResponder(resp *http.Response) (result ApplicationInsightsComponentBillingFeatures, 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  
   120  // Update update current billing features for an Application Insights component.
   121  // Parameters:
   122  // resourceGroupName - the name of the resource group. The name is case insensitive.
   123  // resourceName - the name of the Application Insights component resource.
   124  // billingFeaturesProperties - properties that need to be specified to update billing features for an
   125  // Application Insights component.
   126  func (client ComponentCurrentBillingFeaturesClient) Update(ctx context.Context, resourceGroupName string, resourceName string, billingFeaturesProperties ApplicationInsightsComponentBillingFeatures) (result ApplicationInsightsComponentBillingFeatures, err error) {
   127  	if tracing.IsEnabled() {
   128  		ctx = tracing.StartSpan(ctx, fqdn+"/ComponentCurrentBillingFeaturesClient.Update")
   129  		defer func() {
   130  			sc := -1
   131  			if result.Response.Response != nil {
   132  				sc = result.Response.Response.StatusCode
   133  			}
   134  			tracing.EndSpan(ctx, sc, err)
   135  		}()
   136  	}
   137  	if err := validation.Validate([]validation.Validation{
   138  		{TargetValue: resourceGroupName,
   139  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   140  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   141  		{TargetValue: client.SubscriptionID,
   142  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
   143  		return result, validation.NewError("insights.ComponentCurrentBillingFeaturesClient", "Update", err.Error())
   144  	}
   145  
   146  	req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceName, billingFeaturesProperties)
   147  	if err != nil {
   148  		err = autorest.NewErrorWithError(err, "insights.ComponentCurrentBillingFeaturesClient", "Update", nil, "Failure preparing request")
   149  		return
   150  	}
   151  
   152  	resp, err := client.UpdateSender(req)
   153  	if err != nil {
   154  		result.Response = autorest.Response{Response: resp}
   155  		err = autorest.NewErrorWithError(err, "insights.ComponentCurrentBillingFeaturesClient", "Update", resp, "Failure sending request")
   156  		return
   157  	}
   158  
   159  	result, err = client.UpdateResponder(resp)
   160  	if err != nil {
   161  		err = autorest.NewErrorWithError(err, "insights.ComponentCurrentBillingFeaturesClient", "Update", resp, "Failure responding to request")
   162  		return
   163  	}
   164  
   165  	return
   166  }
   167  
   168  // UpdatePreparer prepares the Update request.
   169  func (client ComponentCurrentBillingFeaturesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, billingFeaturesProperties ApplicationInsightsComponentBillingFeatures) (*http.Request, error) {
   170  	pathParameters := map[string]interface{}{
   171  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   172  		"resourceName":      autorest.Encode("path", resourceName),
   173  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   174  	}
   175  
   176  	const APIVersion = "2015-05-01"
   177  	queryParameters := map[string]interface{}{
   178  		"api-version": APIVersion,
   179  	}
   180  
   181  	preparer := autorest.CreatePreparer(
   182  		autorest.AsContentType("application/json; charset=utf-8"),
   183  		autorest.AsPut(),
   184  		autorest.WithBaseURL(client.BaseURI),
   185  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/currentbillingfeatures", pathParameters),
   186  		autorest.WithJSON(billingFeaturesProperties),
   187  		autorest.WithQueryParameters(queryParameters))
   188  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   189  }
   190  
   191  // UpdateSender sends the Update request. The method will close the
   192  // http.Response Body if it receives an error.
   193  func (client ComponentCurrentBillingFeaturesClient) UpdateSender(req *http.Request) (*http.Response, error) {
   194  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   195  }
   196  
   197  // UpdateResponder handles the response to the Update request. The method always
   198  // closes the http.Response Body.
   199  func (client ComponentCurrentBillingFeaturesClient) UpdateResponder(resp *http.Response) (result ApplicationInsightsComponentBillingFeatures, err error) {
   200  	err = autorest.Respond(
   201  		resp,
   202  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   203  		autorest.ByUnmarshallingJSON(&result),
   204  		autorest.ByClosing())
   205  	result.Response = autorest.Response{Response: resp}
   206  	return
   207  }
   208  

View as plain text