...

Source file src/github.com/Azure/azure-sdk-for-go/services/appinsights/mgmt/2015-05-01/insights/proactivedetectionconfigurations.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  // ProactiveDetectionConfigurationsClient is the composite Swagger for Application Insights Management Client
    19  type ProactiveDetectionConfigurationsClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewProactiveDetectionConfigurationsClient creates an instance of the ProactiveDetectionConfigurationsClient client.
    24  func NewProactiveDetectionConfigurationsClient(subscriptionID string) ProactiveDetectionConfigurationsClient {
    25  	return NewProactiveDetectionConfigurationsClientWithBaseURI(DefaultBaseURI, subscriptionID)
    26  }
    27  
    28  // NewProactiveDetectionConfigurationsClientWithBaseURI creates an instance of the
    29  // ProactiveDetectionConfigurationsClient client using a custom endpoint.  Use this when interacting with an Azure
    30  // cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
    31  func NewProactiveDetectionConfigurationsClientWithBaseURI(baseURI string, subscriptionID string) ProactiveDetectionConfigurationsClient {
    32  	return ProactiveDetectionConfigurationsClient{NewWithBaseURI(baseURI, subscriptionID)}
    33  }
    34  
    35  // Get get the ProactiveDetection configuration for this configuration id.
    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  // configurationID - the ProactiveDetection configuration ID. This is unique within a Application Insights
    40  // component.
    41  func (client ProactiveDetectionConfigurationsClient) Get(ctx context.Context, resourceGroupName string, resourceName string, configurationID string) (result ApplicationInsightsComponentProactiveDetectionConfiguration, err error) {
    42  	if tracing.IsEnabled() {
    43  		ctx = tracing.StartSpan(ctx, fqdn+"/ProactiveDetectionConfigurationsClient.Get")
    44  		defer func() {
    45  			sc := -1
    46  			if result.Response.Response != nil {
    47  				sc = result.Response.Response.StatusCode
    48  			}
    49  			tracing.EndSpan(ctx, sc, err)
    50  		}()
    51  	}
    52  	if err := validation.Validate([]validation.Validation{
    53  		{TargetValue: resourceGroupName,
    54  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
    55  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
    56  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
    57  		{TargetValue: client.SubscriptionID,
    58  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
    59  		return result, validation.NewError("insights.ProactiveDetectionConfigurationsClient", "Get", err.Error())
    60  	}
    61  
    62  	req, err := client.GetPreparer(ctx, resourceGroupName, resourceName, configurationID)
    63  	if err != nil {
    64  		err = autorest.NewErrorWithError(err, "insights.ProactiveDetectionConfigurationsClient", "Get", nil, "Failure preparing request")
    65  		return
    66  	}
    67  
    68  	resp, err := client.GetSender(req)
    69  	if err != nil {
    70  		result.Response = autorest.Response{Response: resp}
    71  		err = autorest.NewErrorWithError(err, "insights.ProactiveDetectionConfigurationsClient", "Get", resp, "Failure sending request")
    72  		return
    73  	}
    74  
    75  	result, err = client.GetResponder(resp)
    76  	if err != nil {
    77  		err = autorest.NewErrorWithError(err, "insights.ProactiveDetectionConfigurationsClient", "Get", resp, "Failure responding to request")
    78  		return
    79  	}
    80  
    81  	return
    82  }
    83  
    84  // GetPreparer prepares the Get request.
    85  func (client ProactiveDetectionConfigurationsClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string, configurationID string) (*http.Request, error) {
    86  	pathParameters := map[string]interface{}{
    87  		"ConfigurationId":   autorest.Encode("path", configurationID),
    88  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
    89  		"resourceName":      autorest.Encode("path", resourceName),
    90  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
    91  	}
    92  
    93  	const APIVersion = "2015-05-01"
    94  	queryParameters := map[string]interface{}{
    95  		"api-version": APIVersion,
    96  	}
    97  
    98  	preparer := autorest.CreatePreparer(
    99  		autorest.AsGet(),
   100  		autorest.WithBaseURL(client.BaseURI),
   101  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ProactiveDetectionConfigs/{ConfigurationId}", pathParameters),
   102  		autorest.WithQueryParameters(queryParameters))
   103  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   104  }
   105  
   106  // GetSender sends the Get request. The method will close the
   107  // http.Response Body if it receives an error.
   108  func (client ProactiveDetectionConfigurationsClient) GetSender(req *http.Request) (*http.Response, error) {
   109  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   110  }
   111  
   112  // GetResponder handles the response to the Get request. The method always
   113  // closes the http.Response Body.
   114  func (client ProactiveDetectionConfigurationsClient) GetResponder(resp *http.Response) (result ApplicationInsightsComponentProactiveDetectionConfiguration, err error) {
   115  	err = autorest.Respond(
   116  		resp,
   117  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   118  		autorest.ByUnmarshallingJSON(&result),
   119  		autorest.ByClosing())
   120  	result.Response = autorest.Response{Response: resp}
   121  	return
   122  }
   123  
   124  // List gets a list of ProactiveDetection configurations of an Application Insights component.
   125  // Parameters:
   126  // resourceGroupName - the name of the resource group. The name is case insensitive.
   127  // resourceName - the name of the Application Insights component resource.
   128  func (client ProactiveDetectionConfigurationsClient) List(ctx context.Context, resourceGroupName string, resourceName string) (result ListApplicationInsightsComponentProactiveDetectionConfiguration, err error) {
   129  	if tracing.IsEnabled() {
   130  		ctx = tracing.StartSpan(ctx, fqdn+"/ProactiveDetectionConfigurationsClient.List")
   131  		defer func() {
   132  			sc := -1
   133  			if result.Response.Response != nil {
   134  				sc = result.Response.Response.StatusCode
   135  			}
   136  			tracing.EndSpan(ctx, sc, err)
   137  		}()
   138  	}
   139  	if err := validation.Validate([]validation.Validation{
   140  		{TargetValue: resourceGroupName,
   141  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   142  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   143  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
   144  		{TargetValue: client.SubscriptionID,
   145  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
   146  		return result, validation.NewError("insights.ProactiveDetectionConfigurationsClient", "List", err.Error())
   147  	}
   148  
   149  	req, err := client.ListPreparer(ctx, resourceGroupName, resourceName)
   150  	if err != nil {
   151  		err = autorest.NewErrorWithError(err, "insights.ProactiveDetectionConfigurationsClient", "List", nil, "Failure preparing request")
   152  		return
   153  	}
   154  
   155  	resp, err := client.ListSender(req)
   156  	if err != nil {
   157  		result.Response = autorest.Response{Response: resp}
   158  		err = autorest.NewErrorWithError(err, "insights.ProactiveDetectionConfigurationsClient", "List", resp, "Failure sending request")
   159  		return
   160  	}
   161  
   162  	result, err = client.ListResponder(resp)
   163  	if err != nil {
   164  		err = autorest.NewErrorWithError(err, "insights.ProactiveDetectionConfigurationsClient", "List", resp, "Failure responding to request")
   165  		return
   166  	}
   167  
   168  	return
   169  }
   170  
   171  // ListPreparer prepares the List request.
   172  func (client ProactiveDetectionConfigurationsClient) ListPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) {
   173  	pathParameters := map[string]interface{}{
   174  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   175  		"resourceName":      autorest.Encode("path", resourceName),
   176  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   177  	}
   178  
   179  	const APIVersion = "2015-05-01"
   180  	queryParameters := map[string]interface{}{
   181  		"api-version": APIVersion,
   182  	}
   183  
   184  	preparer := autorest.CreatePreparer(
   185  		autorest.AsGet(),
   186  		autorest.WithBaseURL(client.BaseURI),
   187  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ProactiveDetectionConfigs", pathParameters),
   188  		autorest.WithQueryParameters(queryParameters))
   189  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   190  }
   191  
   192  // ListSender sends the List request. The method will close the
   193  // http.Response Body if it receives an error.
   194  func (client ProactiveDetectionConfigurationsClient) ListSender(req *http.Request) (*http.Response, error) {
   195  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   196  }
   197  
   198  // ListResponder handles the response to the List request. The method always
   199  // closes the http.Response Body.
   200  func (client ProactiveDetectionConfigurationsClient) ListResponder(resp *http.Response) (result ListApplicationInsightsComponentProactiveDetectionConfiguration, err error) {
   201  	err = autorest.Respond(
   202  		resp,
   203  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   204  		autorest.ByUnmarshallingJSON(&result.Value),
   205  		autorest.ByClosing())
   206  	result.Response = autorest.Response{Response: resp}
   207  	return
   208  }
   209  
   210  // Update update the ProactiveDetection configuration for this configuration id.
   211  // Parameters:
   212  // resourceGroupName - the name of the resource group. The name is case insensitive.
   213  // resourceName - the name of the Application Insights component resource.
   214  // configurationID - the ProactiveDetection configuration ID. This is unique within a Application Insights
   215  // component.
   216  // proactiveDetectionProperties - properties that need to be specified to update the ProactiveDetection
   217  // configuration.
   218  func (client ProactiveDetectionConfigurationsClient) Update(ctx context.Context, resourceGroupName string, resourceName string, configurationID string, proactiveDetectionProperties ApplicationInsightsComponentProactiveDetectionConfiguration) (result ApplicationInsightsComponentProactiveDetectionConfiguration, err error) {
   219  	if tracing.IsEnabled() {
   220  		ctx = tracing.StartSpan(ctx, fqdn+"/ProactiveDetectionConfigurationsClient.Update")
   221  		defer func() {
   222  			sc := -1
   223  			if result.Response.Response != nil {
   224  				sc = result.Response.Response.StatusCode
   225  			}
   226  			tracing.EndSpan(ctx, sc, err)
   227  		}()
   228  	}
   229  	if err := validation.Validate([]validation.Validation{
   230  		{TargetValue: resourceGroupName,
   231  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   232  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   233  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
   234  		{TargetValue: client.SubscriptionID,
   235  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
   236  		return result, validation.NewError("insights.ProactiveDetectionConfigurationsClient", "Update", err.Error())
   237  	}
   238  
   239  	req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceName, configurationID, proactiveDetectionProperties)
   240  	if err != nil {
   241  		err = autorest.NewErrorWithError(err, "insights.ProactiveDetectionConfigurationsClient", "Update", nil, "Failure preparing request")
   242  		return
   243  	}
   244  
   245  	resp, err := client.UpdateSender(req)
   246  	if err != nil {
   247  		result.Response = autorest.Response{Response: resp}
   248  		err = autorest.NewErrorWithError(err, "insights.ProactiveDetectionConfigurationsClient", "Update", resp, "Failure sending request")
   249  		return
   250  	}
   251  
   252  	result, err = client.UpdateResponder(resp)
   253  	if err != nil {
   254  		err = autorest.NewErrorWithError(err, "insights.ProactiveDetectionConfigurationsClient", "Update", resp, "Failure responding to request")
   255  		return
   256  	}
   257  
   258  	return
   259  }
   260  
   261  // UpdatePreparer prepares the Update request.
   262  func (client ProactiveDetectionConfigurationsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, configurationID string, proactiveDetectionProperties ApplicationInsightsComponentProactiveDetectionConfiguration) (*http.Request, error) {
   263  	pathParameters := map[string]interface{}{
   264  		"ConfigurationId":   autorest.Encode("path", configurationID),
   265  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   266  		"resourceName":      autorest.Encode("path", resourceName),
   267  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   268  	}
   269  
   270  	const APIVersion = "2015-05-01"
   271  	queryParameters := map[string]interface{}{
   272  		"api-version": APIVersion,
   273  	}
   274  
   275  	preparer := autorest.CreatePreparer(
   276  		autorest.AsContentType("application/json; charset=utf-8"),
   277  		autorest.AsPut(),
   278  		autorest.WithBaseURL(client.BaseURI),
   279  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ProactiveDetectionConfigs/{ConfigurationId}", pathParameters),
   280  		autorest.WithJSON(proactiveDetectionProperties),
   281  		autorest.WithQueryParameters(queryParameters))
   282  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   283  }
   284  
   285  // UpdateSender sends the Update request. The method will close the
   286  // http.Response Body if it receives an error.
   287  func (client ProactiveDetectionConfigurationsClient) UpdateSender(req *http.Request) (*http.Response, error) {
   288  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   289  }
   290  
   291  // UpdateResponder handles the response to the Update request. The method always
   292  // closes the http.Response Body.
   293  func (client ProactiveDetectionConfigurationsClient) UpdateResponder(resp *http.Response) (result ApplicationInsightsComponentProactiveDetectionConfiguration, err error) {
   294  	err = autorest.Respond(
   295  		resp,
   296  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   297  		autorest.ByUnmarshallingJSON(&result),
   298  		autorest.ByClosing())
   299  	result.Response = autorest.Response{Response: resp}
   300  	return
   301  }
   302  

View as plain text