From f05b00fd905c2be3ce125760c2eba627684fa9b5 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Sun, 4 Feb 2018 07:34:51 +0000 Subject: [PATCH] Generated from 0b82ba534dc6251cb7eeb885072e59254c59d54e Add collectionFormat to comma-separated tags list parameter for favorites - generating API in CSharp generated errors --- .../mgmt/2015-05-01/insights/api_keys.go | 263 ++++ .../mgmt/2015-05-01/insights/apikeys.go | 313 ----- .../mgmt/2015-05-01/insights/client.go | 52 +- .../insights/component_available_features.go | 90 ++ .../component_current_billing_features.go | 155 +++ .../component_feature_capabilities.go | 90 ++ .../insights/component_quota_status.go | 90 ++ .../componentcurrentbillingfeatures.go | 178 --- .../insights/componentquotastatus.go | 107 -- .../mgmt/2015-05-01/insights/components.go | 594 ++++----- .../insights/export_configurations.go | 329 +++++ .../insights/exportconfigurations.go | 386 ------ .../mgmt/2015-05-01/insights/favorite.go | 259 ++++ .../mgmt/2015-05-01/insights/favorites.go | 106 ++ .../mgmt/2015-05-01/insights/marshalling.go | 98 ++ .../mgmt/2015-05-01/insights/models.go | 1067 +++++++++-------- .../mgmt/2015-05-01/insights/operations.go | 117 +- .../proactive_detection_configurations.go | 211 ++++ .../2015-05-01/insights/responder_policy.go | 81 ++ .../2015-05-01/insights/response_error.go | 110 ++ .../mgmt/2015-05-01/insights/validation.go | 381 ++++++ .../mgmt/2015-05-01/insights/version.go | 4 +- .../2015-05-01/insights/web_test_locations.go | 90 ++ .../mgmt/2015-05-01/insights/web_tests.go | 370 ++++++ .../mgmt/2015-05-01/insights/webtests.go | 506 -------- 25 files changed, 3581 insertions(+), 2466 deletions(-) create mode 100644 services/appinsights/mgmt/2015-05-01/insights/api_keys.go delete mode 100644 services/appinsights/mgmt/2015-05-01/insights/apikeys.go create mode 100644 services/appinsights/mgmt/2015-05-01/insights/component_available_features.go create mode 100644 services/appinsights/mgmt/2015-05-01/insights/component_current_billing_features.go create mode 100644 services/appinsights/mgmt/2015-05-01/insights/component_feature_capabilities.go create mode 100644 services/appinsights/mgmt/2015-05-01/insights/component_quota_status.go delete mode 100644 services/appinsights/mgmt/2015-05-01/insights/componentcurrentbillingfeatures.go delete mode 100644 services/appinsights/mgmt/2015-05-01/insights/componentquotastatus.go create mode 100644 services/appinsights/mgmt/2015-05-01/insights/export_configurations.go delete mode 100644 services/appinsights/mgmt/2015-05-01/insights/exportconfigurations.go create mode 100644 services/appinsights/mgmt/2015-05-01/insights/favorite.go create mode 100644 services/appinsights/mgmt/2015-05-01/insights/favorites.go create mode 100644 services/appinsights/mgmt/2015-05-01/insights/marshalling.go create mode 100644 services/appinsights/mgmt/2015-05-01/insights/proactive_detection_configurations.go create mode 100644 services/appinsights/mgmt/2015-05-01/insights/responder_policy.go create mode 100644 services/appinsights/mgmt/2015-05-01/insights/response_error.go create mode 100644 services/appinsights/mgmt/2015-05-01/insights/validation.go create mode 100644 services/appinsights/mgmt/2015-05-01/insights/web_test_locations.go create mode 100644 services/appinsights/mgmt/2015-05-01/insights/web_tests.go delete mode 100644 services/appinsights/mgmt/2015-05-01/insights/webtests.go diff --git a/services/appinsights/mgmt/2015-05-01/insights/api_keys.go b/services/appinsights/mgmt/2015-05-01/insights/api_keys.go new file mode 100644 index 000000000000..35e6431a4088 --- /dev/null +++ b/services/appinsights/mgmt/2015-05-01/insights/api_keys.go @@ -0,0 +1,263 @@ +package insights + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "bytes" + "context" + "encoding/json" + "github.com/Azure/azure-pipeline-go/pipeline" + "io/ioutil" + "net/http" +) + +// APIKeysClient is the composite Swagger for Application Insights Management Client +type APIKeysClient struct { + ManagementClient +} + +// NewAPIKeysClient creates an instance of the APIKeysClient client. +func NewAPIKeysClient(p pipeline.Pipeline) APIKeysClient { + return APIKeysClient{NewManagementClient(p)} +} + +// Create create an API Key of an Application Insights component. +// +// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights component +// resource. APIKeyProperties is properties that need to be specified to create an API key of a Application Insights +// component. +func (client APIKeysClient) Create(ctx context.Context, resourceGroupName string, resourceName string, APIKeyProperties APIKeyRequest) (*ApplicationInsightsComponentAPIKey, error) { + req, err := client.createPreparer(resourceGroupName, resourceName, APIKeyProperties) + if err != nil { + return nil, err + } + resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.createResponder}, req) + if err != nil { + return nil, err + } + return resp.(*ApplicationInsightsComponentAPIKey), err +} + +// createPreparer prepares the Create request. +func (client APIKeysClient) createPreparer(resourceGroupName string, resourceName string, APIKeyProperties APIKeyRequest) (pipeline.Request, error) { + u := client.url + u.Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/ApiKeys" + req, err := pipeline.NewRequest("POST", u, nil) + if err != nil { + return req, pipeline.NewError(err, "failed to create request") + } + params := req.URL.Query() + params.Set("api-version", APIVersion) + req.URL.RawQuery = params.Encode() + b, err := json.Marshal(APIKeyProperties) + if err != nil { + return req, pipeline.NewError(err, "failed to marshal request body") + } + req.Header.Set("Content-Type", "application/json") + err = req.SetBody(bytes.NewReader(b)) + if err != nil { + return req, pipeline.NewError(err, "failed to set request body") + } + return req, nil +} + +// createResponder handles the response to the Create request. +func (client APIKeysClient) createResponder(resp pipeline.Response) (pipeline.Response, error) { + err := validateResponse(resp, http.StatusOK) + if resp == nil { + return nil, err + } + result := &ApplicationInsightsComponentAPIKey{rawResponse: resp.Response()} + if err != nil { + return result, err + } + defer resp.Response().Body.Close() + b, err := ioutil.ReadAll(resp.Response().Body) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to read response body") + } + if len(b) > 0 { + err = json.Unmarshal(b, result) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to unmarshal response body") + } + } + return result, nil +} + +// Delete delete an API Key of an Application Insights component. +// +// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights component +// resource. keyID is the API Key ID. This is unique within a Application Insights component. +func (client APIKeysClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, keyID string) (*ApplicationInsightsComponentAPIKey, error) { + req, err := client.deletePreparer(resourceGroupName, resourceName, keyID) + if err != nil { + return nil, err + } + resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.deleteResponder}, req) + if err != nil { + return nil, err + } + return resp.(*ApplicationInsightsComponentAPIKey), err +} + +// deletePreparer prepares the Delete request. +func (client APIKeysClient) deletePreparer(resourceGroupName string, resourceName string, keyID string) (pipeline.Request, error) { + u := client.url + u.Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/APIKeys/{keyId}" + req, err := pipeline.NewRequest("DELETE", u, nil) + if err != nil { + return req, pipeline.NewError(err, "failed to create request") + } + params := req.URL.Query() + params.Set("api-version", APIVersion) + req.URL.RawQuery = params.Encode() + return req, nil +} + +// deleteResponder handles the response to the Delete request. +func (client APIKeysClient) deleteResponder(resp pipeline.Response) (pipeline.Response, error) { + err := validateResponse(resp, http.StatusOK) + if resp == nil { + return nil, err + } + result := &ApplicationInsightsComponentAPIKey{rawResponse: resp.Response()} + if err != nil { + return result, err + } + defer resp.Response().Body.Close() + b, err := ioutil.ReadAll(resp.Response().Body) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to read response body") + } + if len(b) > 0 { + err = json.Unmarshal(b, result) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to unmarshal response body") + } + } + return result, nil +} + +// Get get the API Key for this key id. +// +// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights component +// resource. keyID is the API Key ID. This is unique within a Application Insights component. +func (client APIKeysClient) Get(ctx context.Context, resourceGroupName string, resourceName string, keyID string) (*ApplicationInsightsComponentAPIKey, error) { + req, err := client.getPreparer(resourceGroupName, resourceName, keyID) + if err != nil { + return nil, err + } + resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.getResponder}, req) + if err != nil { + return nil, err + } + return resp.(*ApplicationInsightsComponentAPIKey), err +} + +// getPreparer prepares the Get request. +func (client APIKeysClient) getPreparer(resourceGroupName string, resourceName string, keyID string) (pipeline.Request, error) { + u := client.url + u.Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/APIKeys/{keyId}" + req, err := pipeline.NewRequest("GET", u, nil) + if err != nil { + return req, pipeline.NewError(err, "failed to create request") + } + params := req.URL.Query() + params.Set("api-version", APIVersion) + req.URL.RawQuery = params.Encode() + return req, nil +} + +// getResponder handles the response to the Get request. +func (client APIKeysClient) getResponder(resp pipeline.Response) (pipeline.Response, error) { + err := validateResponse(resp, http.StatusOK) + if resp == nil { + return nil, err + } + result := &ApplicationInsightsComponentAPIKey{rawResponse: resp.Response()} + if err != nil { + return result, err + } + defer resp.Response().Body.Close() + b, err := ioutil.ReadAll(resp.Response().Body) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to read response body") + } + if len(b) > 0 { + err = json.Unmarshal(b, result) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to unmarshal response body") + } + } + return result, nil +} + +// List gets a list of API keys of an Application Insights component. +// +// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights component +// resource. +func (client APIKeysClient) List(ctx context.Context, resourceGroupName string, resourceName string) (*ApplicationInsightsComponentAPIKeyListResult, error) { + req, err := client.listPreparer(resourceGroupName, resourceName) + if err != nil { + return nil, err + } + resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.listResponder}, req) + if err != nil { + return nil, err + } + return resp.(*ApplicationInsightsComponentAPIKeyListResult), err +} + +// listPreparer prepares the List request. +func (client APIKeysClient) listPreparer(resourceGroupName string, resourceName string) (pipeline.Request, error) { + u := client.url + u.Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/ApiKeys" + req, err := pipeline.NewRequest("GET", u, nil) + if err != nil { + return req, pipeline.NewError(err, "failed to create request") + } + params := req.URL.Query() + params.Set("api-version", APIVersion) + req.URL.RawQuery = params.Encode() + return req, nil +} + +// listResponder handles the response to the List request. +func (client APIKeysClient) listResponder(resp pipeline.Response) (pipeline.Response, error) { + err := validateResponse(resp, http.StatusOK) + if resp == nil { + return nil, err + } + result := &ApplicationInsightsComponentAPIKeyListResult{rawResponse: resp.Response()} + if err != nil { + return result, err + } + defer resp.Response().Body.Close() + b, err := ioutil.ReadAll(resp.Response().Body) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to read response body") + } + if len(b) > 0 { + err = json.Unmarshal(b, result) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to unmarshal response body") + } + } + return result, nil +} diff --git a/services/appinsights/mgmt/2015-05-01/insights/apikeys.go b/services/appinsights/mgmt/2015-05-01/insights/apikeys.go deleted file mode 100644 index 727d2a551c86..000000000000 --- a/services/appinsights/mgmt/2015-05-01/insights/apikeys.go +++ /dev/null @@ -1,313 +0,0 @@ -package insights - -// Copyright (c) Microsoft and contributors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "net/http" -) - -// APIKeysClient is the composite Swagger for Application Insights Management Client -type APIKeysClient struct { - BaseClient -} - -// NewAPIKeysClient creates an instance of the APIKeysClient client. -func NewAPIKeysClient(subscriptionID string) APIKeysClient { - return NewAPIKeysClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewAPIKeysClientWithBaseURI creates an instance of the APIKeysClient client. -func NewAPIKeysClientWithBaseURI(baseURI string, subscriptionID string) APIKeysClient { - return APIKeysClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// Create create an API Key of an Application Insights component. -// -// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights component -// resource. APIKeyProperties is properties that need to be specified to create an API key of a Application Insights -// component. -func (client APIKeysClient) Create(ctx context.Context, resourceGroupName string, resourceName string, APIKeyProperties APIKeyRequest) (result ApplicationInsightsComponentAPIKey, err error) { - req, err := client.CreatePreparer(ctx, resourceGroupName, resourceName, APIKeyProperties) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.APIKeysClient", "Create", nil, "Failure preparing request") - return - } - - resp, err := client.CreateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "insights.APIKeysClient", "Create", resp, "Failure sending request") - return - } - - result, err = client.CreateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.APIKeysClient", "Create", resp, "Failure responding to request") - } - - return -} - -// CreatePreparer prepares the Create request. -func (client APIKeysClient) CreatePreparer(ctx context.Context, resourceGroupName string, resourceName string, APIKeyProperties APIKeyRequest) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "resourceName": autorest.Encode("path", resourceName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2015-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsJSON(), - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/ApiKeys", pathParameters), - autorest.WithJSON(APIKeyProperties), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateSender sends the Create request. The method will close the -// http.Response Body if it receives an error. -func (client APIKeysClient) CreateSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// CreateResponder handles the response to the Create request. The method always -// closes the http.Response Body. -func (client APIKeysClient) CreateResponder(resp *http.Response) (result ApplicationInsightsComponentAPIKey, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Delete delete an API Key of an Application Insights component. -// -// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights component -// resource. keyID is the API Key ID. This is unique within a Application Insights component. -func (client APIKeysClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, keyID string) (result ApplicationInsightsComponentAPIKey, err error) { - req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName, keyID) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.APIKeysClient", "Delete", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "insights.APIKeysClient", "Delete", resp, "Failure sending request") - return - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.APIKeysClient", "Delete", resp, "Failure responding to request") - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client APIKeysClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string, keyID string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "keyId": autorest.Encode("path", keyID), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "resourceName": autorest.Encode("path", resourceName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2015-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/APIKeys/{keyId}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client APIKeysClient) DeleteSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client APIKeysClient) DeleteResponder(resp *http.Response) (result ApplicationInsightsComponentAPIKey, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Get get the API Key for this key id. -// -// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights component -// resource. keyID is the API Key ID. This is unique within a Application Insights component. -func (client APIKeysClient) Get(ctx context.Context, resourceGroupName string, resourceName string, keyID string) (result ApplicationInsightsComponentAPIKey, err error) { - req, err := client.GetPreparer(ctx, resourceGroupName, resourceName, keyID) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.APIKeysClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "insights.APIKeysClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.APIKeysClient", "Get", resp, "Failure responding to request") - } - - return -} - -// GetPreparer prepares the Get request. -func (client APIKeysClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string, keyID string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "keyId": autorest.Encode("path", keyID), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "resourceName": autorest.Encode("path", resourceName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2015-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/APIKeys/{keyId}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client APIKeysClient) GetSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client APIKeysClient) GetResponder(resp *http.Response) (result ApplicationInsightsComponentAPIKey, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// List gets a list of API keys of an Application Insights component. -// -// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights component -// resource. -func (client APIKeysClient) List(ctx context.Context, resourceGroupName string, resourceName string) (result ApplicationInsightsComponentAPIKeyListResult, err error) { - req, err := client.ListPreparer(ctx, resourceGroupName, resourceName) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.APIKeysClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "insights.APIKeysClient", "List", resp, "Failure sending request") - return - } - - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.APIKeysClient", "List", resp, "Failure responding to request") - } - - return -} - -// ListPreparer prepares the List request. -func (client APIKeysClient) ListPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "resourceName": autorest.Encode("path", resourceName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2015-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/ApiKeys", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client APIKeysClient) ListSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client APIKeysClient) ListResponder(resp *http.Response) (result ApplicationInsightsComponentAPIKeyListResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/services/appinsights/mgmt/2015-05-01/insights/client.go b/services/appinsights/mgmt/2015-05-01/insights/client.go index 8508d449fead..d312decf6b5b 100644 --- a/services/appinsights/mgmt/2015-05-01/insights/client.go +++ b/services/appinsights/mgmt/2015-05-01/insights/client.go @@ -1,6 +1,3 @@ -// Package insights implements the Azure ARM Insights service API version 2015-05-01. -// -// Composite Swagger for Application Insights Management Client package insights // Copyright (c) Microsoft and contributors. All rights reserved. @@ -21,31 +18,46 @@ package insights // Changes may cause incorrect behavior and will be lost if the code is regenerated. import ( - "github.com/Azure/go-autorest/autorest" + "github.com/Azure/azure-pipeline-go/pipeline" + "net/url" ) const ( - // DefaultBaseURI is the default URI used for the service Insights - DefaultBaseURI = "https://management.azure.com" + // ServiceVersion specifies the version of the operations used in this package. + ServiceVersion = "2015-05-01" + // DefaultBaseURL is the default URL used for the service Insights + DefaultBaseURL = "https://management.azure.com" ) -// BaseClient is the base client for Insights. -type BaseClient struct { - autorest.Client - BaseURI string - SubscriptionID string +// ManagementClient is the base client for Insights. +type ManagementClient struct { + url url.URL + p pipeline.Pipeline } -// New creates an instance of the BaseClient client. -func New(subscriptionID string) BaseClient { - return NewWithBaseURI(DefaultBaseURI, subscriptionID) +// NewManagementClient creates an instance of the ManagementClient client. +func NewManagementClient(p pipeline.Pipeline) ManagementClient { + u, err := url.Parse(DefaultBaseURL) + if err != nil { + panic(err) + } + return NewManagementClientWithURL(*u, p) } -// NewWithBaseURI creates an instance of the BaseClient client. -func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { - return BaseClient{ - Client: autorest.NewClientWithUserAgent(UserAgent()), - BaseURI: baseURI, - SubscriptionID: subscriptionID, +// NewManagementClientWithURL creates an instance of the ManagementClient client. +func NewManagementClientWithURL(url url.URL, p pipeline.Pipeline) ManagementClient { + return ManagementClient{ + url: url, + p: p, } } + +// URL returns a copy of the URL for this client. +func (mc ManagementClient) URL() url.URL { + return mc.url +} + +// Pipeline returns the pipeline for this client. +func (mc ManagementClient) Pipeline() pipeline.Pipeline { + return mc.p +} diff --git a/services/appinsights/mgmt/2015-05-01/insights/component_available_features.go b/services/appinsights/mgmt/2015-05-01/insights/component_available_features.go new file mode 100644 index 000000000000..35508979b30c --- /dev/null +++ b/services/appinsights/mgmt/2015-05-01/insights/component_available_features.go @@ -0,0 +1,90 @@ +package insights + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "encoding/json" + "github.com/Azure/azure-pipeline-go/pipeline" + "io/ioutil" + "net/http" +) + +// ComponentAvailableFeaturesClient is the composite Swagger for Application Insights Management Client +type ComponentAvailableFeaturesClient struct { + ManagementClient +} + +// NewComponentAvailableFeaturesClient creates an instance of the ComponentAvailableFeaturesClient client. +func NewComponentAvailableFeaturesClient(p pipeline.Pipeline) ComponentAvailableFeaturesClient { + return ComponentAvailableFeaturesClient{NewManagementClient(p)} +} + +// Get returns all available features of the application insights component. +// +// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights component +// resource. +func (client ComponentAvailableFeaturesClient) Get(ctx context.Context, resourceGroupName string, resourceName string) (*ApplicationInsightsComponentAvailableFeatures, error) { + req, err := client.getPreparer(resourceGroupName, resourceName) + if err != nil { + return nil, err + } + resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.getResponder}, req) + if err != nil { + return nil, err + } + return resp.(*ApplicationInsightsComponentAvailableFeatures), err +} + +// getPreparer prepares the Get request. +func (client ComponentAvailableFeaturesClient) getPreparer(resourceGroupName string, resourceName string) (pipeline.Request, error) { + u := client.url + u.Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/getavailablebillingfeatures" + req, err := pipeline.NewRequest("GET", u, nil) + if err != nil { + return req, pipeline.NewError(err, "failed to create request") + } + params := req.URL.Query() + params.Set("api-version", APIVersion) + req.URL.RawQuery = params.Encode() + return req, nil +} + +// getResponder handles the response to the Get request. +func (client ComponentAvailableFeaturesClient) getResponder(resp pipeline.Response) (pipeline.Response, error) { + err := validateResponse(resp, http.StatusOK) + if resp == nil { + return nil, err + } + result := &ApplicationInsightsComponentAvailableFeatures{rawResponse: resp.Response()} + if err != nil { + return result, err + } + defer resp.Response().Body.Close() + b, err := ioutil.ReadAll(resp.Response().Body) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to read response body") + } + if len(b) > 0 { + err = json.Unmarshal(b, result) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to unmarshal response body") + } + } + return result, nil +} diff --git a/services/appinsights/mgmt/2015-05-01/insights/component_current_billing_features.go b/services/appinsights/mgmt/2015-05-01/insights/component_current_billing_features.go new file mode 100644 index 000000000000..c21831fc7c33 --- /dev/null +++ b/services/appinsights/mgmt/2015-05-01/insights/component_current_billing_features.go @@ -0,0 +1,155 @@ +package insights + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "bytes" + "context" + "encoding/json" + "github.com/Azure/azure-pipeline-go/pipeline" + "io/ioutil" + "net/http" +) + +// ComponentCurrentBillingFeaturesClient is the composite Swagger for Application Insights Management Client +type ComponentCurrentBillingFeaturesClient struct { + ManagementClient +} + +// NewComponentCurrentBillingFeaturesClient creates an instance of the ComponentCurrentBillingFeaturesClient client. +func NewComponentCurrentBillingFeaturesClient(p pipeline.Pipeline) ComponentCurrentBillingFeaturesClient { + return ComponentCurrentBillingFeaturesClient{NewManagementClient(p)} +} + +// Get returns current billing features for an Application Insights component. +// +// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights component +// resource. +func (client ComponentCurrentBillingFeaturesClient) Get(ctx context.Context, resourceGroupName string, resourceName string) (*ApplicationInsightsComponentBillingFeatures, error) { + req, err := client.getPreparer(resourceGroupName, resourceName) + if err != nil { + return nil, err + } + resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.getResponder}, req) + if err != nil { + return nil, err + } + return resp.(*ApplicationInsightsComponentBillingFeatures), err +} + +// getPreparer prepares the Get request. +func (client ComponentCurrentBillingFeaturesClient) getPreparer(resourceGroupName string, resourceName string) (pipeline.Request, error) { + u := client.url + u.Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/currentbillingfeatures" + req, err := pipeline.NewRequest("GET", u, nil) + if err != nil { + return req, pipeline.NewError(err, "failed to create request") + } + params := req.URL.Query() + params.Set("api-version", APIVersion) + req.URL.RawQuery = params.Encode() + return req, nil +} + +// getResponder handles the response to the Get request. +func (client ComponentCurrentBillingFeaturesClient) getResponder(resp pipeline.Response) (pipeline.Response, error) { + err := validateResponse(resp, http.StatusOK) + if resp == nil { + return nil, err + } + result := &ApplicationInsightsComponentBillingFeatures{rawResponse: resp.Response()} + if err != nil { + return result, err + } + defer resp.Response().Body.Close() + b, err := ioutil.ReadAll(resp.Response().Body) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to read response body") + } + if len(b) > 0 { + err = json.Unmarshal(b, result) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to unmarshal response body") + } + } + return result, nil +} + +// Update update current billing features for an Application Insights component. +// +// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights component +// resource. billingFeaturesProperties is properties that need to be specified to update billing features for an +// Application Insights component. +func (client ComponentCurrentBillingFeaturesClient) Update(ctx context.Context, resourceGroupName string, resourceName string, billingFeaturesProperties ApplicationInsightsComponentBillingFeatures) (*ApplicationInsightsComponentBillingFeatures, error) { + req, err := client.updatePreparer(resourceGroupName, resourceName, billingFeaturesProperties) + if err != nil { + return nil, err + } + resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.updateResponder}, req) + if err != nil { + return nil, err + } + return resp.(*ApplicationInsightsComponentBillingFeatures), err +} + +// updatePreparer prepares the Update request. +func (client ComponentCurrentBillingFeaturesClient) updatePreparer(resourceGroupName string, resourceName string, billingFeaturesProperties ApplicationInsightsComponentBillingFeatures) (pipeline.Request, error) { + u := client.url + u.Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/currentbillingfeatures" + req, err := pipeline.NewRequest("PUT", u, nil) + if err != nil { + return req, pipeline.NewError(err, "failed to create request") + } + params := req.URL.Query() + params.Set("api-version", APIVersion) + req.URL.RawQuery = params.Encode() + b, err := json.Marshal(billingFeaturesProperties) + if err != nil { + return req, pipeline.NewError(err, "failed to marshal request body") + } + req.Header.Set("Content-Type", "application/json") + err = req.SetBody(bytes.NewReader(b)) + if err != nil { + return req, pipeline.NewError(err, "failed to set request body") + } + return req, nil +} + +// updateResponder handles the response to the Update request. +func (client ComponentCurrentBillingFeaturesClient) updateResponder(resp pipeline.Response) (pipeline.Response, error) { + err := validateResponse(resp, http.StatusOK) + if resp == nil { + return nil, err + } + result := &ApplicationInsightsComponentBillingFeatures{rawResponse: resp.Response()} + if err != nil { + return result, err + } + defer resp.Response().Body.Close() + b, err := ioutil.ReadAll(resp.Response().Body) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to read response body") + } + if len(b) > 0 { + err = json.Unmarshal(b, result) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to unmarshal response body") + } + } + return result, nil +} diff --git a/services/appinsights/mgmt/2015-05-01/insights/component_feature_capabilities.go b/services/appinsights/mgmt/2015-05-01/insights/component_feature_capabilities.go new file mode 100644 index 000000000000..f5c6aaedf9c7 --- /dev/null +++ b/services/appinsights/mgmt/2015-05-01/insights/component_feature_capabilities.go @@ -0,0 +1,90 @@ +package insights + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "encoding/json" + "github.com/Azure/azure-pipeline-go/pipeline" + "io/ioutil" + "net/http" +) + +// ComponentFeatureCapabilitiesClient is the composite Swagger for Application Insights Management Client +type ComponentFeatureCapabilitiesClient struct { + ManagementClient +} + +// NewComponentFeatureCapabilitiesClient creates an instance of the ComponentFeatureCapabilitiesClient client. +func NewComponentFeatureCapabilitiesClient(p pipeline.Pipeline) ComponentFeatureCapabilitiesClient { + return ComponentFeatureCapabilitiesClient{NewManagementClient(p)} +} + +// Get returns feature capabilites of the application insights component. +// +// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights component +// resource. +func (client ComponentFeatureCapabilitiesClient) Get(ctx context.Context, resourceGroupName string, resourceName string) (*ApplicationInsightsComponentFeatureCapabilities, error) { + req, err := client.getPreparer(resourceGroupName, resourceName) + if err != nil { + return nil, err + } + resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.getResponder}, req) + if err != nil { + return nil, err + } + return resp.(*ApplicationInsightsComponentFeatureCapabilities), err +} + +// getPreparer prepares the Get request. +func (client ComponentFeatureCapabilitiesClient) getPreparer(resourceGroupName string, resourceName string) (pipeline.Request, error) { + u := client.url + u.Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/featurecapabilities" + req, err := pipeline.NewRequest("GET", u, nil) + if err != nil { + return req, pipeline.NewError(err, "failed to create request") + } + params := req.URL.Query() + params.Set("api-version", APIVersion) + req.URL.RawQuery = params.Encode() + return req, nil +} + +// getResponder handles the response to the Get request. +func (client ComponentFeatureCapabilitiesClient) getResponder(resp pipeline.Response) (pipeline.Response, error) { + err := validateResponse(resp, http.StatusOK) + if resp == nil { + return nil, err + } + result := &ApplicationInsightsComponentFeatureCapabilities{rawResponse: resp.Response()} + if err != nil { + return result, err + } + defer resp.Response().Body.Close() + b, err := ioutil.ReadAll(resp.Response().Body) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to read response body") + } + if len(b) > 0 { + err = json.Unmarshal(b, result) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to unmarshal response body") + } + } + return result, nil +} diff --git a/services/appinsights/mgmt/2015-05-01/insights/component_quota_status.go b/services/appinsights/mgmt/2015-05-01/insights/component_quota_status.go new file mode 100644 index 000000000000..12ee55b0d03a --- /dev/null +++ b/services/appinsights/mgmt/2015-05-01/insights/component_quota_status.go @@ -0,0 +1,90 @@ +package insights + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "encoding/json" + "github.com/Azure/azure-pipeline-go/pipeline" + "io/ioutil" + "net/http" +) + +// ComponentQuotaStatusClient is the composite Swagger for Application Insights Management Client +type ComponentQuotaStatusClient struct { + ManagementClient +} + +// NewComponentQuotaStatusClient creates an instance of the ComponentQuotaStatusClient client. +func NewComponentQuotaStatusClient(p pipeline.Pipeline) ComponentQuotaStatusClient { + return ComponentQuotaStatusClient{NewManagementClient(p)} +} + +// Get returns daily data volume cap (quota) status for an Application Insights component. +// +// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights component +// resource. +func (client ComponentQuotaStatusClient) Get(ctx context.Context, resourceGroupName string, resourceName string) (*ApplicationInsightsComponentQuotaStatus, error) { + req, err := client.getPreparer(resourceGroupName, resourceName) + if err != nil { + return nil, err + } + resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.getResponder}, req) + if err != nil { + return nil, err + } + return resp.(*ApplicationInsightsComponentQuotaStatus), err +} + +// getPreparer prepares the Get request. +func (client ComponentQuotaStatusClient) getPreparer(resourceGroupName string, resourceName string) (pipeline.Request, error) { + u := client.url + u.Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/quotastatus" + req, err := pipeline.NewRequest("GET", u, nil) + if err != nil { + return req, pipeline.NewError(err, "failed to create request") + } + params := req.URL.Query() + params.Set("api-version", APIVersion) + req.URL.RawQuery = params.Encode() + return req, nil +} + +// getResponder handles the response to the Get request. +func (client ComponentQuotaStatusClient) getResponder(resp pipeline.Response) (pipeline.Response, error) { + err := validateResponse(resp, http.StatusOK) + if resp == nil { + return nil, err + } + result := &ApplicationInsightsComponentQuotaStatus{rawResponse: resp.Response()} + if err != nil { + return result, err + } + defer resp.Response().Body.Close() + b, err := ioutil.ReadAll(resp.Response().Body) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to read response body") + } + if len(b) > 0 { + err = json.Unmarshal(b, result) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to unmarshal response body") + } + } + return result, nil +} diff --git a/services/appinsights/mgmt/2015-05-01/insights/componentcurrentbillingfeatures.go b/services/appinsights/mgmt/2015-05-01/insights/componentcurrentbillingfeatures.go deleted file mode 100644 index 81217343a0e3..000000000000 --- a/services/appinsights/mgmt/2015-05-01/insights/componentcurrentbillingfeatures.go +++ /dev/null @@ -1,178 +0,0 @@ -package insights - -// Copyright (c) Microsoft and contributors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "net/http" -) - -// ComponentCurrentBillingFeaturesClient is the composite Swagger for Application Insights Management Client -type ComponentCurrentBillingFeaturesClient struct { - BaseClient -} - -// NewComponentCurrentBillingFeaturesClient creates an instance of the ComponentCurrentBillingFeaturesClient client. -func NewComponentCurrentBillingFeaturesClient(subscriptionID string) ComponentCurrentBillingFeaturesClient { - return NewComponentCurrentBillingFeaturesClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewComponentCurrentBillingFeaturesClientWithBaseURI creates an instance of the ComponentCurrentBillingFeaturesClient -// client. -func NewComponentCurrentBillingFeaturesClientWithBaseURI(baseURI string, subscriptionID string) ComponentCurrentBillingFeaturesClient { - return ComponentCurrentBillingFeaturesClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// Get returns current billing features for an Application Insights component. -// -// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights component -// resource. -func (client ComponentCurrentBillingFeaturesClient) Get(ctx context.Context, resourceGroupName string, resourceName string) (result ApplicationInsightsComponentBillingFeatures, err error) { - req, err := client.GetPreparer(ctx, resourceGroupName, resourceName) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.ComponentCurrentBillingFeaturesClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "insights.ComponentCurrentBillingFeaturesClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.ComponentCurrentBillingFeaturesClient", "Get", resp, "Failure responding to request") - } - - return -} - -// GetPreparer prepares the Get request. -func (client ComponentCurrentBillingFeaturesClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "resourceName": autorest.Encode("path", resourceName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2015-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/currentbillingfeatures", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client ComponentCurrentBillingFeaturesClient) GetSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client ComponentCurrentBillingFeaturesClient) GetResponder(resp *http.Response) (result ApplicationInsightsComponentBillingFeatures, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Update update current billing features for an Application Insights component. -// -// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights component -// resource. billingFeaturesProperties is properties that need to be specified to update billing features for an -// Application Insights component. -func (client ComponentCurrentBillingFeaturesClient) Update(ctx context.Context, resourceGroupName string, resourceName string, billingFeaturesProperties ApplicationInsightsComponentBillingFeatures) (result ApplicationInsightsComponentBillingFeatures, err error) { - req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceName, billingFeaturesProperties) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.ComponentCurrentBillingFeaturesClient", "Update", nil, "Failure preparing request") - return - } - - resp, err := client.UpdateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "insights.ComponentCurrentBillingFeaturesClient", "Update", resp, "Failure sending request") - return - } - - result, err = client.UpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.ComponentCurrentBillingFeaturesClient", "Update", resp, "Failure responding to request") - } - - return -} - -// UpdatePreparer prepares the Update request. -func (client ComponentCurrentBillingFeaturesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, billingFeaturesProperties ApplicationInsightsComponentBillingFeatures) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "resourceName": autorest.Encode("path", resourceName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2015-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsJSON(), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/currentbillingfeatures", pathParameters), - autorest.WithJSON(billingFeaturesProperties), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// UpdateSender sends the Update request. The method will close the -// http.Response Body if it receives an error. -func (client ComponentCurrentBillingFeaturesClient) UpdateSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// UpdateResponder handles the response to the Update request. The method always -// closes the http.Response Body. -func (client ComponentCurrentBillingFeaturesClient) UpdateResponder(resp *http.Response) (result ApplicationInsightsComponentBillingFeatures, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/services/appinsights/mgmt/2015-05-01/insights/componentquotastatus.go b/services/appinsights/mgmt/2015-05-01/insights/componentquotastatus.go deleted file mode 100644 index 760159b6a5f2..000000000000 --- a/services/appinsights/mgmt/2015-05-01/insights/componentquotastatus.go +++ /dev/null @@ -1,107 +0,0 @@ -package insights - -// Copyright (c) Microsoft and contributors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "net/http" -) - -// ComponentQuotaStatusClient is the composite Swagger for Application Insights Management Client -type ComponentQuotaStatusClient struct { - BaseClient -} - -// NewComponentQuotaStatusClient creates an instance of the ComponentQuotaStatusClient client. -func NewComponentQuotaStatusClient(subscriptionID string) ComponentQuotaStatusClient { - return NewComponentQuotaStatusClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewComponentQuotaStatusClientWithBaseURI creates an instance of the ComponentQuotaStatusClient client. -func NewComponentQuotaStatusClientWithBaseURI(baseURI string, subscriptionID string) ComponentQuotaStatusClient { - return ComponentQuotaStatusClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// Get returns daily data volume cap (quota) status for an Application Insights component. -// -// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights component -// resource. -func (client ComponentQuotaStatusClient) Get(ctx context.Context, resourceGroupName string, resourceName string) (result ApplicationInsightsComponentQuotaStatus, err error) { - req, err := client.GetPreparer(ctx, resourceGroupName, resourceName) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.ComponentQuotaStatusClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "insights.ComponentQuotaStatusClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.ComponentQuotaStatusClient", "Get", resp, "Failure responding to request") - } - - return -} - -// GetPreparer prepares the Get request. -func (client ComponentQuotaStatusClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "resourceName": autorest.Encode("path", resourceName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2015-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/quotastatus", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client ComponentQuotaStatusClient) GetSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client ComponentQuotaStatusClient) GetResponder(resp *http.Response) (result ApplicationInsightsComponentQuotaStatus, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/services/appinsights/mgmt/2015-05-01/insights/components.go b/services/appinsights/mgmt/2015-05-01/insights/components.go index 2b80ba95d0b6..372d974b025c 100644 --- a/services/appinsights/mgmt/2015-05-01/insights/components.go +++ b/services/appinsights/mgmt/2015-05-01/insights/components.go @@ -18,26 +18,22 @@ package insights // Changes may cause incorrect behavior and will be lost if the code is regenerated. import ( + "bytes" "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" + "encoding/json" + "github.com/Azure/azure-pipeline-go/pipeline" + "io/ioutil" "net/http" ) // ComponentsClient is the composite Swagger for Application Insights Management Client type ComponentsClient struct { - BaseClient + ManagementClient } // NewComponentsClient creates an instance of the ComponentsClient client. -func NewComponentsClient(subscriptionID string) ComponentsClient { - return NewComponentsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewComponentsClientWithBaseURI creates an instance of the ComponentsClient client. -func NewComponentsClientWithBaseURI(baseURI string, subscriptionID string) ComponentsClient { - return ComponentsClient{NewWithBaseURI(baseURI, subscriptionID)} +func NewComponentsClient(p pipeline.Pipeline) ComponentsClient { + return ComponentsClient{NewManagementClient(p)} } // CreateOrUpdate creates (or updates) an Application Insights component. Note: You cannot specify a different value @@ -45,458 +41,326 @@ func NewComponentsClientWithBaseURI(baseURI string, subscriptionID string) Compo // // resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights component // resource. insightProperties is properties that need to be specified to create an Application Insights component. -func (client ComponentsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, insightProperties ApplicationInsightsComponent) (result ApplicationInsightsComponent, err error) { - if err := validation.Validate([]validation.Validation{ - {TargetValue: insightProperties, - Constraints: []validation.Constraint{{Target: "insightProperties.Kind", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "insights.ComponentsClient", "CreateOrUpdate") +func (client ComponentsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, insightProperties ApplicationInsightsComponent) (*ApplicationInsightsComponent, error) { + if err := validate([]validation{ + {targetValue: insightProperties, + constraints: []constraint{{target: "insightProperties.Kind", name: null, rule: true, chain: nil}}}}); err != nil { + return nil, err } - - req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceName, insightProperties) + req, err := client.createOrUpdatePreparer(resourceGroupName, resourceName, insightProperties) if err != nil { - err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "CreateOrUpdate", nil, "Failure preparing request") - return + return nil, err } - - resp, err := client.CreateOrUpdateSender(req) + resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.createOrUpdateResponder}, req) if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "CreateOrUpdate", resp, "Failure sending request") - return + return nil, err } + return resp.(*ApplicationInsightsComponent), err +} - result, err = client.CreateOrUpdateResponder(resp) +// createOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ComponentsClient) createOrUpdatePreparer(resourceGroupName string, resourceName string, insightProperties ApplicationInsightsComponent) (pipeline.Request, error) { + u := client.url + u.Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}" + req, err := pipeline.NewRequest("PUT", u, nil) if err != nil { - err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "CreateOrUpdate", resp, "Failure responding to request") + return req, pipeline.NewError(err, "failed to create request") } - - return -} - -// CreateOrUpdatePreparer prepares the CreateOrUpdate request. -func (client ComponentsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, insightProperties ApplicationInsightsComponent) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "resourceName": autorest.Encode("path", resourceName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), + params := req.URL.Query() + params.Set("api-version", APIVersion) + req.URL.RawQuery = params.Encode() + b, err := json.Marshal(insightProperties) + if err != nil { + return req, pipeline.NewError(err, "failed to marshal request body") } - - const APIVersion = "2015-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, + req.Header.Set("Content-Type", "application/json") + err = req.SetBody(bytes.NewReader(b)) + if err != nil { + return req, pipeline.NewError(err, "failed to set request body") } - - preparer := autorest.CreatePreparer( - autorest.AsJSON(), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}", pathParameters), - autorest.WithJSON(insightProperties), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) + return req, nil } -// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (client ComponentsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (client ComponentsClient) CreateOrUpdateResponder(resp *http.Response) (result ApplicationInsightsComponent, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return +// createOrUpdateResponder handles the response to the CreateOrUpdate request. +func (client ComponentsClient) createOrUpdateResponder(resp pipeline.Response) (pipeline.Response, error) { + err := validateResponse(resp, http.StatusOK) + if resp == nil { + return nil, err + } + result := &ApplicationInsightsComponent{rawResponse: resp.Response()} + if err != nil { + return result, err + } + defer resp.Response().Body.Close() + b, err := ioutil.ReadAll(resp.Response().Body) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to read response body") + } + if len(b) > 0 { + err = json.Unmarshal(b, result) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to unmarshal response body") + } + } + return result, nil } // Delete deletes an Application Insights component. // // resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights component // resource. -func (client ComponentsClient) Delete(ctx context.Context, resourceGroupName string, resourceName string) (result autorest.Response, err error) { - req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName) +func (client ComponentsClient) Delete(ctx context.Context, resourceGroupName string, resourceName string) (*http.Response, error) { + req, err := client.deletePreparer(resourceGroupName, resourceName) if err != nil { - err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "Delete", nil, "Failure preparing request") - return + return nil, err } - - resp, err := client.DeleteSender(req) + resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.deleteResponder}, req) if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "Delete", resp, "Failure sending request") - return + return nil, err } + return resp.Response(), err +} - result, err = client.DeleteResponder(resp) +// deletePreparer prepares the Delete request. +func (client ComponentsClient) deletePreparer(resourceGroupName string, resourceName string) (pipeline.Request, error) { + u := client.url + u.Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}" + req, err := pipeline.NewRequest("DELETE", u, nil) if err != nil { - err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "Delete", resp, "Failure responding to request") + return req, pipeline.NewError(err, "failed to create request") } - - return + params := req.URL.Query() + params.Set("api-version", APIVersion) + req.URL.RawQuery = params.Encode() + return req, nil } -// DeletePreparer prepares the Delete request. -func (client ComponentsClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "resourceName": autorest.Encode("path", resourceName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), +// deleteResponder handles the response to the Delete request. +func (client ComponentsClient) deleteResponder(resp pipeline.Response) (pipeline.Response, error) { + err := validateResponse(resp, http.StatusOK, http.StatusNoContent) + if resp == nil { + return nil, err } - - const APIVersion = "2015-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client ComponentsClient) DeleteSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client ComponentsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return + return resp, err } // Get returns an Application Insights component. // // resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights component // resource. -func (client ComponentsClient) Get(ctx context.Context, resourceGroupName string, resourceName string) (result ApplicationInsightsComponent, err error) { - req, err := client.GetPreparer(ctx, resourceGroupName, resourceName) +func (client ComponentsClient) Get(ctx context.Context, resourceGroupName string, resourceName string) (*ApplicationInsightsComponent, error) { + req, err := client.getPreparer(resourceGroupName, resourceName) if err != nil { - err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "Get", nil, "Failure preparing request") - return + return nil, err } - - resp, err := client.GetSender(req) + resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.getResponder}, req) if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "Get", resp, "Failure sending request") - return + return nil, err } + return resp.(*ApplicationInsightsComponent), err +} - result, err = client.GetResponder(resp) +// getPreparer prepares the Get request. +func (client ComponentsClient) getPreparer(resourceGroupName string, resourceName string) (pipeline.Request, error) { + u := client.url + u.Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}" + req, err := pipeline.NewRequest("GET", u, nil) if err != nil { - err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "Get", resp, "Failure responding to request") + return req, pipeline.NewError(err, "failed to create request") } - - return + params := req.URL.Query() + params.Set("api-version", APIVersion) + req.URL.RawQuery = params.Encode() + return req, nil } -// GetPreparer prepares the Get request. -func (client ComponentsClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "resourceName": autorest.Encode("path", resourceName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), +// getResponder handles the response to the Get request. +func (client ComponentsClient) getResponder(resp pipeline.Response) (pipeline.Response, error) { + err := validateResponse(resp, http.StatusOK) + if resp == nil { + return nil, err } - - const APIVersion = "2015-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, + result := &ApplicationInsightsComponent{rawResponse: resp.Response()} + if err != nil { + return result, err } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client ComponentsClient) GetSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client ComponentsClient) GetResponder(resp *http.Response) (result ApplicationInsightsComponent, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return + defer resp.Response().Body.Close() + b, err := ioutil.ReadAll(resp.Response().Body) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to read response body") + } + if len(b) > 0 { + err = json.Unmarshal(b, result) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to unmarshal response body") + } + } + return result, nil } // List gets a list of all Application Insights components within a subscription. -func (client ComponentsClient) List(ctx context.Context) (result ApplicationInsightsComponentListResultPage, err error) { - result.fn = client.listNextResults - req, err := client.ListPreparer(ctx) +func (client ComponentsClient) List(ctx context.Context) (*ApplicationInsightsComponentListResult, error) { + req, err := client.listPreparer() if err != nil { - err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "List", nil, "Failure preparing request") - return + return nil, err } - - resp, err := client.ListSender(req) + resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.listResponder}, req) if err != nil { - result.aiclr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "List", resp, "Failure sending request") - return + return nil, err } + return resp.(*ApplicationInsightsComponentListResult), err +} - result.aiclr, err = client.ListResponder(resp) +// listPreparer prepares the List request. +func (client ComponentsClient) listPreparer() (pipeline.Request, error) { + u := client.url + u.Path = "/subscriptions/{subscriptionId}/providers/microsoft.insights/components" + req, err := pipeline.NewRequest("GET", u, nil) if err != nil { - err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "List", resp, "Failure responding to request") + return req, pipeline.NewError(err, "failed to create request") } - - return + params := req.URL.Query() + params.Set("api-version", APIVersion) + req.URL.RawQuery = params.Encode() + return req, nil } -// ListPreparer prepares the List request. -func (client ComponentsClient) ListPreparer(ctx context.Context) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "subscriptionId": autorest.Encode("path", client.SubscriptionID), +// listResponder handles the response to the List request. +func (client ComponentsClient) listResponder(resp pipeline.Response) (pipeline.Response, error) { + err := validateResponse(resp, http.StatusOK) + if resp == nil { + return nil, err } - - const APIVersion = "2015-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/microsoft.insights/components", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client ComponentsClient) ListSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client ComponentsClient) ListResponder(resp *http.Response) (result ApplicationInsightsComponentListResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listNextResults retrieves the next set of results, if any. -func (client ComponentsClient) listNextResults(lastResults ApplicationInsightsComponentListResult) (result ApplicationInsightsComponentListResult, err error) { - req, err := lastResults.applicationInsightsComponentListResultPreparer() + result := &ApplicationInsightsComponentListResult{rawResponse: resp.Response()} if err != nil { - return result, autorest.NewErrorWithError(err, "insights.ComponentsClient", "listNextResults", nil, "Failure preparing next results request") + return result, err } - if req == nil { - return - } - resp, err := client.ListSender(req) + defer resp.Response().Body.Close() + b, err := ioutil.ReadAll(resp.Response().Body) if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "insights.ComponentsClient", "listNextResults", resp, "Failure sending next results request") + return result, NewResponseError(err, resp.Response(), "failed to read response body") } - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "listNextResults", resp, "Failure responding to next results request") + if len(b) > 0 { + err = json.Unmarshal(b, result) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to unmarshal response body") + } } - return -} - -// ListComplete enumerates all values, automatically crossing page boundaries as required. -func (client ComponentsClient) ListComplete(ctx context.Context) (result ApplicationInsightsComponentListResultIterator, err error) { - result.page, err = client.List(ctx) - return + return result, nil } // ListByResourceGroup gets a list of Application Insights components within a resource group. // // resourceGroupName is the name of the resource group. -func (client ComponentsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ApplicationInsightsComponentListResultPage, err error) { - result.fn = client.listByResourceGroupNextResults - req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) +func (client ComponentsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (*ApplicationInsightsComponentListResult, error) { + req, err := client.listByResourceGroupPreparer(resourceGroupName) if err != nil { - err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "ListByResourceGroup", nil, "Failure preparing request") - return + return nil, err } - - resp, err := client.ListByResourceGroupSender(req) + resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.listByResourceGroupResponder}, req) if err != nil { - result.aiclr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "ListByResourceGroup", resp, "Failure sending request") - return + return nil, err } + return resp.(*ApplicationInsightsComponentListResult), err +} - result.aiclr, err = client.ListByResourceGroupResponder(resp) +// listByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client ComponentsClient) listByResourceGroupPreparer(resourceGroupName string) (pipeline.Request, error) { + u := client.url + u.Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components" + req, err := pipeline.NewRequest("GET", u, nil) if err != nil { - err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "ListByResourceGroup", resp, "Failure responding to request") + return req, pipeline.NewError(err, "failed to create request") } - - return + params := req.URL.Query() + params.Set("api-version", APIVersion) + req.URL.RawQuery = params.Encode() + return req, nil } -// ListByResourceGroupPreparer prepares the ListByResourceGroup request. -func (client ComponentsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2015-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, +// listByResourceGroupResponder handles the response to the ListByResourceGroup request. +func (client ComponentsClient) listByResourceGroupResponder(resp pipeline.Response) (pipeline.Response, error) { + err := validateResponse(resp, http.StatusOK) + if resp == nil { + return nil, err } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the -// http.Response Body if it receives an error. -func (client ComponentsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always -// closes the http.Response Body. -func (client ComponentsClient) ListByResourceGroupResponder(resp *http.Response) (result ApplicationInsightsComponentListResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listByResourceGroupNextResults retrieves the next set of results, if any. -func (client ComponentsClient) listByResourceGroupNextResults(lastResults ApplicationInsightsComponentListResult) (result ApplicationInsightsComponentListResult, err error) { - req, err := lastResults.applicationInsightsComponentListResultPreparer() + result := &ApplicationInsightsComponentListResult{rawResponse: resp.Response()} if err != nil { - return result, autorest.NewErrorWithError(err, "insights.ComponentsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return + return result, err } - resp, err := client.ListByResourceGroupSender(req) + defer resp.Response().Body.Close() + b, err := ioutil.ReadAll(resp.Response().Body) if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "insights.ComponentsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + return result, NewResponseError(err, resp.Response(), "failed to read response body") } - result, err = client.ListByResourceGroupResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + if len(b) > 0 { + err = json.Unmarshal(b, result) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to unmarshal response body") + } } - return -} - -// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. -func (client ComponentsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ApplicationInsightsComponentListResultIterator, err error) { - result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) - return + return result, nil } // UpdateTags updates an existing component's tags. To update other fields use the CreateOrUpdate method. // // resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights component // resource. componentTags is updated tag information to set into the component instance. -func (client ComponentsClient) UpdateTags(ctx context.Context, resourceGroupName string, resourceName string, componentTags TagsResource) (result ApplicationInsightsComponent, err error) { - req, err := client.UpdateTagsPreparer(ctx, resourceGroupName, resourceName, componentTags) +func (client ComponentsClient) UpdateTags(ctx context.Context, resourceGroupName string, resourceName string, componentTags TagsResource) (*ApplicationInsightsComponent, error) { + req, err := client.updateTagsPreparer(resourceGroupName, resourceName, componentTags) if err != nil { - err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "UpdateTags", nil, "Failure preparing request") - return + return nil, err } - - resp, err := client.UpdateTagsSender(req) + resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.updateTagsResponder}, req) if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "UpdateTags", resp, "Failure sending request") - return + return nil, err } + return resp.(*ApplicationInsightsComponent), err +} - result, err = client.UpdateTagsResponder(resp) +// updateTagsPreparer prepares the UpdateTags request. +func (client ComponentsClient) updateTagsPreparer(resourceGroupName string, resourceName string, componentTags TagsResource) (pipeline.Request, error) { + u := client.url + u.Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}" + req, err := pipeline.NewRequest("PATCH", u, nil) if err != nil { - err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "UpdateTags", resp, "Failure responding to request") + return req, pipeline.NewError(err, "failed to create request") } - - return -} - -// UpdateTagsPreparer prepares the UpdateTags request. -func (client ComponentsClient) UpdateTagsPreparer(ctx context.Context, resourceGroupName string, resourceName string, componentTags TagsResource) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "resourceName": autorest.Encode("path", resourceName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), + params := req.URL.Query() + params.Set("api-version", APIVersion) + req.URL.RawQuery = params.Encode() + b, err := json.Marshal(componentTags) + if err != nil { + return req, pipeline.NewError(err, "failed to marshal request body") } - - const APIVersion = "2015-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, + req.Header.Set("Content-Type", "application/json") + err = req.SetBody(bytes.NewReader(b)) + if err != nil { + return req, pipeline.NewError(err, "failed to set request body") } - - preparer := autorest.CreatePreparer( - autorest.AsJSON(), - autorest.AsPatch(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}", pathParameters), - autorest.WithJSON(componentTags), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) + return req, nil } -// UpdateTagsSender sends the UpdateTags request. The method will close the -// http.Response Body if it receives an error. -func (client ComponentsClient) UpdateTagsSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// UpdateTagsResponder handles the response to the UpdateTags request. The method always -// closes the http.Response Body. -func (client ComponentsClient) UpdateTagsResponder(resp *http.Response) (result ApplicationInsightsComponent, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return +// updateTagsResponder handles the response to the UpdateTags request. +func (client ComponentsClient) updateTagsResponder(resp pipeline.Response) (pipeline.Response, error) { + err := validateResponse(resp, http.StatusOK) + if resp == nil { + return nil, err + } + result := &ApplicationInsightsComponent{rawResponse: resp.Response()} + if err != nil { + return result, err + } + defer resp.Response().Body.Close() + b, err := ioutil.ReadAll(resp.Response().Body) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to read response body") + } + if len(b) > 0 { + err = json.Unmarshal(b, result) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to unmarshal response body") + } + } + return result, nil } diff --git a/services/appinsights/mgmt/2015-05-01/insights/export_configurations.go b/services/appinsights/mgmt/2015-05-01/insights/export_configurations.go new file mode 100644 index 000000000000..fba49d66d7cb --- /dev/null +++ b/services/appinsights/mgmt/2015-05-01/insights/export_configurations.go @@ -0,0 +1,329 @@ +package insights + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "bytes" + "context" + "encoding/json" + "github.com/Azure/azure-pipeline-go/pipeline" + "io/ioutil" + "net/http" +) + +// ExportConfigurationsClient is the composite Swagger for Application Insights Management Client +type ExportConfigurationsClient struct { + ManagementClient +} + +// NewExportConfigurationsClient creates an instance of the ExportConfigurationsClient client. +func NewExportConfigurationsClient(p pipeline.Pipeline) ExportConfigurationsClient { + return ExportConfigurationsClient{NewManagementClient(p)} +} + +// Create create a Continuous Export configuration of an Application Insights component. +// +// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights component +// resource. exportProperties is properties that need to be specified to create a Continuous Export configuration of a +// Application Insights component. +func (client ExportConfigurationsClient) Create(ctx context.Context, resourceGroupName string, resourceName string, exportProperties ApplicationInsightsComponentExportRequest) (*CreateResponse, error) { + req, err := client.createPreparer(resourceGroupName, resourceName, exportProperties) + if err != nil { + return nil, err + } + resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.createResponder}, req) + if err != nil { + return nil, err + } + return resp.(*CreateResponse), err +} + +// createPreparer prepares the Create request. +func (client ExportConfigurationsClient) createPreparer(resourceGroupName string, resourceName string, exportProperties ApplicationInsightsComponentExportRequest) (pipeline.Request, error) { + u := client.url + u.Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/exportconfiguration" + req, err := pipeline.NewRequest("POST", u, nil) + if err != nil { + return req, pipeline.NewError(err, "failed to create request") + } + params := req.URL.Query() + params.Set("api-version", APIVersion) + req.URL.RawQuery = params.Encode() + b, err := json.Marshal(exportProperties) + if err != nil { + return req, pipeline.NewError(err, "failed to marshal request body") + } + req.Header.Set("Content-Type", "application/json") + err = req.SetBody(bytes.NewReader(b)) + if err != nil { + return req, pipeline.NewError(err, "failed to set request body") + } + return req, nil +} + +// createResponder handles the response to the Create request. +func (client ExportConfigurationsClient) createResponder(resp pipeline.Response) (pipeline.Response, error) { + err := validateResponse(resp, http.StatusOK) + if resp == nil { + return nil, err + } + result := &CreateResponse{rawResponse: resp.Response()} + if err != nil { + return result, err + } + defer resp.Response().Body.Close() + b, err := ioutil.ReadAll(resp.Response().Body) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to read response body") + } + if len(b) > 0 { + err = json.Unmarshal(b, &result.Value) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to unmarshal response body") + } + } + return result, nil +} + +// Delete delete a Continuous Export configuration of an Application Insights component. +// +// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights component +// resource. exportID is the Continuous Export configuration ID. This is unique within a Application Insights +// component. +func (client ExportConfigurationsClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, exportID string) (*ApplicationInsightsComponentExportConfiguration, error) { + req, err := client.deletePreparer(resourceGroupName, resourceName, exportID) + if err != nil { + return nil, err + } + resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.deleteResponder}, req) + if err != nil { + return nil, err + } + return resp.(*ApplicationInsightsComponentExportConfiguration), err +} + +// deletePreparer prepares the Delete request. +func (client ExportConfigurationsClient) deletePreparer(resourceGroupName string, resourceName string, exportID string) (pipeline.Request, error) { + u := client.url + u.Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/exportconfiguration/{exportId}" + req, err := pipeline.NewRequest("DELETE", u, nil) + if err != nil { + return req, pipeline.NewError(err, "failed to create request") + } + params := req.URL.Query() + params.Set("api-version", APIVersion) + req.URL.RawQuery = params.Encode() + return req, nil +} + +// deleteResponder handles the response to the Delete request. +func (client ExportConfigurationsClient) deleteResponder(resp pipeline.Response) (pipeline.Response, error) { + err := validateResponse(resp, http.StatusOK) + if resp == nil { + return nil, err + } + result := &ApplicationInsightsComponentExportConfiguration{rawResponse: resp.Response()} + if err != nil { + return result, err + } + defer resp.Response().Body.Close() + b, err := ioutil.ReadAll(resp.Response().Body) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to read response body") + } + if len(b) > 0 { + err = json.Unmarshal(b, result) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to unmarshal response body") + } + } + return result, nil +} + +// Get get the Continuous Export configuration for this export id. +// +// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights component +// resource. exportID is the Continuous Export configuration ID. This is unique within a Application Insights +// component. +func (client ExportConfigurationsClient) Get(ctx context.Context, resourceGroupName string, resourceName string, exportID string) (*ApplicationInsightsComponentExportConfiguration, error) { + req, err := client.getPreparer(resourceGroupName, resourceName, exportID) + if err != nil { + return nil, err + } + resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.getResponder}, req) + if err != nil { + return nil, err + } + return resp.(*ApplicationInsightsComponentExportConfiguration), err +} + +// getPreparer prepares the Get request. +func (client ExportConfigurationsClient) getPreparer(resourceGroupName string, resourceName string, exportID string) (pipeline.Request, error) { + u := client.url + u.Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/exportconfiguration/{exportId}" + req, err := pipeline.NewRequest("GET", u, nil) + if err != nil { + return req, pipeline.NewError(err, "failed to create request") + } + params := req.URL.Query() + params.Set("api-version", APIVersion) + req.URL.RawQuery = params.Encode() + return req, nil +} + +// getResponder handles the response to the Get request. +func (client ExportConfigurationsClient) getResponder(resp pipeline.Response) (pipeline.Response, error) { + err := validateResponse(resp, http.StatusOK) + if resp == nil { + return nil, err + } + result := &ApplicationInsightsComponentExportConfiguration{rawResponse: resp.Response()} + if err != nil { + return result, err + } + defer resp.Response().Body.Close() + b, err := ioutil.ReadAll(resp.Response().Body) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to read response body") + } + if len(b) > 0 { + err = json.Unmarshal(b, result) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to unmarshal response body") + } + } + return result, nil +} + +// List gets a list of Continuous Export configuration of an Application Insights component. +// +// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights component +// resource. +func (client ExportConfigurationsClient) List(ctx context.Context, resourceGroupName string, resourceName string) (*ListResponse, error) { + req, err := client.listPreparer(resourceGroupName, resourceName) + if err != nil { + return nil, err + } + resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.listResponder}, req) + if err != nil { + return nil, err + } + return resp.(*ListResponse), err +} + +// listPreparer prepares the List request. +func (client ExportConfigurationsClient) listPreparer(resourceGroupName string, resourceName string) (pipeline.Request, error) { + u := client.url + u.Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/exportconfiguration" + req, err := pipeline.NewRequest("GET", u, nil) + if err != nil { + return req, pipeline.NewError(err, "failed to create request") + } + params := req.URL.Query() + params.Set("api-version", APIVersion) + req.URL.RawQuery = params.Encode() + return req, nil +} + +// listResponder handles the response to the List request. +func (client ExportConfigurationsClient) listResponder(resp pipeline.Response) (pipeline.Response, error) { + err := validateResponse(resp, http.StatusOK) + if resp == nil { + return nil, err + } + result := &ListResponse{rawResponse: resp.Response()} + if err != nil { + return result, err + } + defer resp.Response().Body.Close() + b, err := ioutil.ReadAll(resp.Response().Body) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to read response body") + } + if len(b) > 0 { + err = json.Unmarshal(b, &result.Value) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to unmarshal response body") + } + } + return result, nil +} + +// Update update the Continuous Export configuration for this export id. +// +// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights component +// resource. exportID is the Continuous Export configuration ID. This is unique within a Application Insights +// component. exportProperties is properties that need to be specified to update the Continuous Export configuration. +func (client ExportConfigurationsClient) Update(ctx context.Context, resourceGroupName string, resourceName string, exportID string, exportProperties ApplicationInsightsComponentExportRequest) (*ApplicationInsightsComponentExportConfiguration, error) { + req, err := client.updatePreparer(resourceGroupName, resourceName, exportID, exportProperties) + if err != nil { + return nil, err + } + resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.updateResponder}, req) + if err != nil { + return nil, err + } + return resp.(*ApplicationInsightsComponentExportConfiguration), err +} + +// updatePreparer prepares the Update request. +func (client ExportConfigurationsClient) updatePreparer(resourceGroupName string, resourceName string, exportID string, exportProperties ApplicationInsightsComponentExportRequest) (pipeline.Request, error) { + u := client.url + u.Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/exportconfiguration/{exportId}" + req, err := pipeline.NewRequest("PUT", u, nil) + if err != nil { + return req, pipeline.NewError(err, "failed to create request") + } + params := req.URL.Query() + params.Set("api-version", APIVersion) + req.URL.RawQuery = params.Encode() + b, err := json.Marshal(exportProperties) + if err != nil { + return req, pipeline.NewError(err, "failed to marshal request body") + } + req.Header.Set("Content-Type", "application/json") + err = req.SetBody(bytes.NewReader(b)) + if err != nil { + return req, pipeline.NewError(err, "failed to set request body") + } + return req, nil +} + +// updateResponder handles the response to the Update request. +func (client ExportConfigurationsClient) updateResponder(resp pipeline.Response) (pipeline.Response, error) { + err := validateResponse(resp, http.StatusOK) + if resp == nil { + return nil, err + } + result := &ApplicationInsightsComponentExportConfiguration{rawResponse: resp.Response()} + if err != nil { + return result, err + } + defer resp.Response().Body.Close() + b, err := ioutil.ReadAll(resp.Response().Body) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to read response body") + } + if len(b) > 0 { + err = json.Unmarshal(b, result) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to unmarshal response body") + } + } + return result, nil +} diff --git a/services/appinsights/mgmt/2015-05-01/insights/exportconfigurations.go b/services/appinsights/mgmt/2015-05-01/insights/exportconfigurations.go deleted file mode 100644 index 7ad42a9c51d9..000000000000 --- a/services/appinsights/mgmt/2015-05-01/insights/exportconfigurations.go +++ /dev/null @@ -1,386 +0,0 @@ -package insights - -// Copyright (c) Microsoft and contributors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "net/http" -) - -// ExportConfigurationsClient is the composite Swagger for Application Insights Management Client -type ExportConfigurationsClient struct { - BaseClient -} - -// NewExportConfigurationsClient creates an instance of the ExportConfigurationsClient client. -func NewExportConfigurationsClient(subscriptionID string) ExportConfigurationsClient { - return NewExportConfigurationsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewExportConfigurationsClientWithBaseURI creates an instance of the ExportConfigurationsClient client. -func NewExportConfigurationsClientWithBaseURI(baseURI string, subscriptionID string) ExportConfigurationsClient { - return ExportConfigurationsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// Create create a Continuous Export configuration of an Application Insights component. -// -// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights component -// resource. exportProperties is properties that need to be specified to create a Continuous Export configuration of a -// Application Insights component. -func (client ExportConfigurationsClient) Create(ctx context.Context, resourceGroupName string, resourceName string, exportProperties ApplicationInsightsComponentExportRequest) (result ListApplicationInsightsComponentExportConfiguration, err error) { - req, err := client.CreatePreparer(ctx, resourceGroupName, resourceName, exportProperties) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.ExportConfigurationsClient", "Create", nil, "Failure preparing request") - return - } - - resp, err := client.CreateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "insights.ExportConfigurationsClient", "Create", resp, "Failure sending request") - return - } - - result, err = client.CreateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.ExportConfigurationsClient", "Create", resp, "Failure responding to request") - } - - return -} - -// CreatePreparer prepares the Create request. -func (client ExportConfigurationsClient) CreatePreparer(ctx context.Context, resourceGroupName string, resourceName string, exportProperties ApplicationInsightsComponentExportRequest) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "resourceName": autorest.Encode("path", resourceName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2015-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsJSON(), - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/exportconfiguration", pathParameters), - autorest.WithJSON(exportProperties), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateSender sends the Create request. The method will close the -// http.Response Body if it receives an error. -func (client ExportConfigurationsClient) CreateSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// CreateResponder handles the response to the Create request. The method always -// closes the http.Response Body. -func (client ExportConfigurationsClient) CreateResponder(resp *http.Response) (result ListApplicationInsightsComponentExportConfiguration, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Value), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Delete delete a Continuous Export configuration of an Application Insights component. -// -// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights component -// resource. exportID is the Continuous Export configuration ID. This is unique within a Application Insights -// component. -func (client ExportConfigurationsClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, exportID string) (result ApplicationInsightsComponentExportConfiguration, err error) { - req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName, exportID) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.ExportConfigurationsClient", "Delete", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "insights.ExportConfigurationsClient", "Delete", resp, "Failure sending request") - return - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.ExportConfigurationsClient", "Delete", resp, "Failure responding to request") - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client ExportConfigurationsClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string, exportID string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "exportId": autorest.Encode("path", exportID), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "resourceName": autorest.Encode("path", resourceName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2015-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/exportconfiguration/{exportId}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client ExportConfigurationsClient) DeleteSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client ExportConfigurationsClient) DeleteResponder(resp *http.Response) (result ApplicationInsightsComponentExportConfiguration, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Get get the Continuous Export configuration for this export id. -// -// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights component -// resource. exportID is the Continuous Export configuration ID. This is unique within a Application Insights -// component. -func (client ExportConfigurationsClient) Get(ctx context.Context, resourceGroupName string, resourceName string, exportID string) (result ApplicationInsightsComponentExportConfiguration, err error) { - req, err := client.GetPreparer(ctx, resourceGroupName, resourceName, exportID) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.ExportConfigurationsClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "insights.ExportConfigurationsClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.ExportConfigurationsClient", "Get", resp, "Failure responding to request") - } - - return -} - -// GetPreparer prepares the Get request. -func (client ExportConfigurationsClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string, exportID string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "exportId": autorest.Encode("path", exportID), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "resourceName": autorest.Encode("path", resourceName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2015-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/exportconfiguration/{exportId}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client ExportConfigurationsClient) GetSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client ExportConfigurationsClient) GetResponder(resp *http.Response) (result ApplicationInsightsComponentExportConfiguration, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// List gets a list of Continuous Export configuration of an Application Insights component. -// -// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights component -// resource. -func (client ExportConfigurationsClient) List(ctx context.Context, resourceGroupName string, resourceName string) (result ListApplicationInsightsComponentExportConfiguration, err error) { - req, err := client.ListPreparer(ctx, resourceGroupName, resourceName) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.ExportConfigurationsClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "insights.ExportConfigurationsClient", "List", resp, "Failure sending request") - return - } - - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.ExportConfigurationsClient", "List", resp, "Failure responding to request") - } - - return -} - -// ListPreparer prepares the List request. -func (client ExportConfigurationsClient) ListPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "resourceName": autorest.Encode("path", resourceName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2015-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/exportconfiguration", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client ExportConfigurationsClient) ListSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client ExportConfigurationsClient) ListResponder(resp *http.Response) (result ListApplicationInsightsComponentExportConfiguration, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Value), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Update update the Continuous Export configuration for this export id. -// -// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights component -// resource. exportID is the Continuous Export configuration ID. This is unique within a Application Insights -// component. exportProperties is properties that need to be specified to update the Continuous Export configuration. -func (client ExportConfigurationsClient) Update(ctx context.Context, resourceGroupName string, resourceName string, exportID string, exportProperties ApplicationInsightsComponentExportRequest) (result ApplicationInsightsComponentExportConfiguration, err error) { - req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceName, exportID, exportProperties) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.ExportConfigurationsClient", "Update", nil, "Failure preparing request") - return - } - - resp, err := client.UpdateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "insights.ExportConfigurationsClient", "Update", resp, "Failure sending request") - return - } - - result, err = client.UpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.ExportConfigurationsClient", "Update", resp, "Failure responding to request") - } - - return -} - -// UpdatePreparer prepares the Update request. -func (client ExportConfigurationsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, exportID string, exportProperties ApplicationInsightsComponentExportRequest) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "exportId": autorest.Encode("path", exportID), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "resourceName": autorest.Encode("path", resourceName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2015-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsJSON(), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/exportconfiguration/{exportId}", pathParameters), - autorest.WithJSON(exportProperties), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// UpdateSender sends the Update request. The method will close the -// http.Response Body if it receives an error. -func (client ExportConfigurationsClient) UpdateSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// UpdateResponder handles the response to the Update request. The method always -// closes the http.Response Body. -func (client ExportConfigurationsClient) UpdateResponder(resp *http.Response) (result ApplicationInsightsComponentExportConfiguration, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/services/appinsights/mgmt/2015-05-01/insights/favorite.go b/services/appinsights/mgmt/2015-05-01/insights/favorite.go new file mode 100644 index 000000000000..00c9e9c7fea2 --- /dev/null +++ b/services/appinsights/mgmt/2015-05-01/insights/favorite.go @@ -0,0 +1,259 @@ +package insights + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "bytes" + "context" + "encoding/json" + "github.com/Azure/azure-pipeline-go/pipeline" + "io/ioutil" + "net/http" +) + +// FavoriteClient is the composite Swagger for Application Insights Management Client +type FavoriteClient struct { + ManagementClient +} + +// NewFavoriteClient creates an instance of the FavoriteClient client. +func NewFavoriteClient(p pipeline.Pipeline) FavoriteClient { + return FavoriteClient{NewManagementClient(p)} +} + +// Add adds a new favorites to an Application Insights component. +// +// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights component +// resource. favoriteID is the Id of a specific favorite defined in the Application Insights component +// favoriteProperties is properties that need to be specified to create a new favorite and add it to an Application +// Insights component. +func (client FavoriteClient) Add(ctx context.Context, resourceGroupName string, resourceName string, favoriteID string, favoriteProperties ApplicationInsightsComponentFavorite) (*ApplicationInsightsComponentFavorite, error) { + req, err := client.addPreparer(resourceGroupName, resourceName, favoriteID, favoriteProperties) + if err != nil { + return nil, err + } + resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.addResponder}, req) + if err != nil { + return nil, err + } + return resp.(*ApplicationInsightsComponentFavorite), err +} + +// addPreparer prepares the Add request. +func (client FavoriteClient) addPreparer(resourceGroupName string, resourceName string, favoriteID string, favoriteProperties ApplicationInsightsComponentFavorite) (pipeline.Request, error) { + u := client.url + u.Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/favorites/{favoriteId}" + req, err := pipeline.NewRequest("PUT", u, nil) + if err != nil { + return req, pipeline.NewError(err, "failed to create request") + } + params := req.URL.Query() + params.Set("api-version", APIVersion) + req.URL.RawQuery = params.Encode() + b, err := json.Marshal(favoriteProperties) + if err != nil { + return req, pipeline.NewError(err, "failed to marshal request body") + } + req.Header.Set("Content-Type", "application/json") + err = req.SetBody(bytes.NewReader(b)) + if err != nil { + return req, pipeline.NewError(err, "failed to set request body") + } + return req, nil +} + +// addResponder handles the response to the Add request. +func (client FavoriteClient) addResponder(resp pipeline.Response) (pipeline.Response, error) { + err := validateResponse(resp, http.StatusOK) + if resp == nil { + return nil, err + } + result := &ApplicationInsightsComponentFavorite{rawResponse: resp.Response()} + if err != nil { + return result, err + } + defer resp.Response().Body.Close() + b, err := ioutil.ReadAll(resp.Response().Body) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to read response body") + } + if len(b) > 0 { + err = json.Unmarshal(b, result) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to unmarshal response body") + } + } + return result, nil +} + +// Delete remove a favorite that is associated to an Application Insights component. +// +// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights component +// resource. favoriteID is the Id of a specific favorite defined in the Application Insights component +func (client FavoriteClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, favoriteID string) (*http.Response, error) { + req, err := client.deletePreparer(resourceGroupName, resourceName, favoriteID) + if err != nil { + return nil, err + } + resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.deleteResponder}, req) + if err != nil { + return nil, err + } + return resp.Response(), err +} + +// deletePreparer prepares the Delete request. +func (client FavoriteClient) deletePreparer(resourceGroupName string, resourceName string, favoriteID string) (pipeline.Request, error) { + u := client.url + u.Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/favorites/{favoriteId}" + req, err := pipeline.NewRequest("DELETE", u, nil) + if err != nil { + return req, pipeline.NewError(err, "failed to create request") + } + params := req.URL.Query() + params.Set("api-version", APIVersion) + req.URL.RawQuery = params.Encode() + return req, nil +} + +// deleteResponder handles the response to the Delete request. +func (client FavoriteClient) deleteResponder(resp pipeline.Response) (pipeline.Response, error) { + err := validateResponse(resp, http.StatusOK) + if resp == nil { + return nil, err + } + return resp, err +} + +// Get get a single favorite by its FavoriteId, defined within an Application Insights component. +// +// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights component +// resource. favoriteID is the Id of a specific favorite defined in the Application Insights component +func (client FavoriteClient) Get(ctx context.Context, resourceGroupName string, resourceName string, favoriteID string) (*ApplicationInsightsComponentFavorite, error) { + req, err := client.getPreparer(resourceGroupName, resourceName, favoriteID) + if err != nil { + return nil, err + } + resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.getResponder}, req) + if err != nil { + return nil, err + } + return resp.(*ApplicationInsightsComponentFavorite), err +} + +// getPreparer prepares the Get request. +func (client FavoriteClient) getPreparer(resourceGroupName string, resourceName string, favoriteID string) (pipeline.Request, error) { + u := client.url + u.Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/favorites/{favoriteId}" + req, err := pipeline.NewRequest("GET", u, nil) + if err != nil { + return req, pipeline.NewError(err, "failed to create request") + } + params := req.URL.Query() + params.Set("api-version", APIVersion) + req.URL.RawQuery = params.Encode() + return req, nil +} + +// getResponder handles the response to the Get request. +func (client FavoriteClient) getResponder(resp pipeline.Response) (pipeline.Response, error) { + err := validateResponse(resp, http.StatusOK) + if resp == nil { + return nil, err + } + result := &ApplicationInsightsComponentFavorite{rawResponse: resp.Response()} + if err != nil { + return result, err + } + defer resp.Response().Body.Close() + b, err := ioutil.ReadAll(resp.Response().Body) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to read response body") + } + if len(b) > 0 { + err = json.Unmarshal(b, result) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to unmarshal response body") + } + } + return result, nil +} + +// Update updates a favorite that has already been added to an Application Insights component. +// +// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights component +// resource. favoriteID is the Id of a specific favorite defined in the Application Insights component +// favoriteProperties is properties that need to be specified to update the existing favorite. +func (client FavoriteClient) Update(ctx context.Context, resourceGroupName string, resourceName string, favoriteID string, favoriteProperties ApplicationInsightsComponentFavorite) (*ApplicationInsightsComponentFavorite, error) { + req, err := client.updatePreparer(resourceGroupName, resourceName, favoriteID, favoriteProperties) + if err != nil { + return nil, err + } + resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.updateResponder}, req) + if err != nil { + return nil, err + } + return resp.(*ApplicationInsightsComponentFavorite), err +} + +// updatePreparer prepares the Update request. +func (client FavoriteClient) updatePreparer(resourceGroupName string, resourceName string, favoriteID string, favoriteProperties ApplicationInsightsComponentFavorite) (pipeline.Request, error) { + u := client.url + u.Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/favorites/{favoriteId}" + req, err := pipeline.NewRequest("PATCH", u, nil) + if err != nil { + return req, pipeline.NewError(err, "failed to create request") + } + params := req.URL.Query() + params.Set("api-version", APIVersion) + req.URL.RawQuery = params.Encode() + b, err := json.Marshal(favoriteProperties) + if err != nil { + return req, pipeline.NewError(err, "failed to marshal request body") + } + req.Header.Set("Content-Type", "application/json") + err = req.SetBody(bytes.NewReader(b)) + if err != nil { + return req, pipeline.NewError(err, "failed to set request body") + } + return req, nil +} + +// updateResponder handles the response to the Update request. +func (client FavoriteClient) updateResponder(resp pipeline.Response) (pipeline.Response, error) { + err := validateResponse(resp, http.StatusOK) + if resp == nil { + return nil, err + } + result := &ApplicationInsightsComponentFavorite{rawResponse: resp.Response()} + if err != nil { + return result, err + } + defer resp.Response().Body.Close() + b, err := ioutil.ReadAll(resp.Response().Body) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to read response body") + } + if len(b) > 0 { + err = json.Unmarshal(b, result) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to unmarshal response body") + } + } + return result, nil +} diff --git a/services/appinsights/mgmt/2015-05-01/insights/favorites.go b/services/appinsights/mgmt/2015-05-01/insights/favorites.go new file mode 100644 index 000000000000..7158662b6248 --- /dev/null +++ b/services/appinsights/mgmt/2015-05-01/insights/favorites.go @@ -0,0 +1,106 @@ +package insights + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "encoding/json" + "fmt" + "github.com/Azure/azure-pipeline-go/pipeline" + "io/ioutil" + "net/http" +) + +// FavoritesClient is the composite Swagger for Application Insights Management Client +type FavoritesClient struct { + ManagementClient +} + +// NewFavoritesClient creates an instance of the FavoritesClient client. +func NewFavoritesClient(p pipeline.Pipeline) FavoritesClient { + return FavoritesClient{NewManagementClient(p)} +} + +// List gets a list of favorites defined within an Application Insights component. +// +// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights component +// resource. favoriteType is the type of favorite. Value can be either shared or user. sourceType is source type of +// favorite to return. When left out, the source type defaults to 'other' (not present in this enum). canFetchContent +// is flag indicating whether or not to return the full content for each applicable favorite. If false, only return +// summary content for favorites. tags is tags that must be present on each favorite returned. +func (client FavoritesClient) List(ctx context.Context, resourceGroupName string, resourceName string, favoriteType string, sourceType FavoriteSourceType, canFetchContent *bool, tags []string) (*ListResponse, error) { + req, err := client.listPreparer(resourceGroupName, resourceName, favoriteType, sourceType, canFetchContent, tags) + if err != nil { + return nil, err + } + resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.listResponder}, req) + if err != nil { + return nil, err + } + return resp.(*ListResponse), err +} + +// listPreparer prepares the List request. +func (client FavoritesClient) listPreparer(resourceGroupName string, resourceName string, favoriteType string, sourceType FavoriteSourceType, canFetchContent *bool, tags []string) (pipeline.Request, error) { + u := client.url + u.Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/favorites" + req, err := pipeline.NewRequest("GET", u, nil) + if err != nil { + return req, pipeline.NewError(err, "failed to create request") + } + params := req.URL.Query() + params.Set("api-version", APIVersion) + if favoriteType != stringNone { + params.Set("favoriteType", fmt.Sprintf("%v", favoriteType)) + } + if sourceType != FavoriteSourceNone { + params.Set("sourceType", fmt.Sprintf("%v", sourceType)) + } + if canFetchContent != nil { + params.Set("canFetchContent", fmt.Sprintf("%v", *canFetchContent)) + } + if tags != nil { + params.Set("tags", fmt.Sprintf("%v", tags, ",")) + } + req.URL.RawQuery = params.Encode() + return req, nil +} + +// listResponder handles the response to the List request. +func (client FavoritesClient) listResponder(resp pipeline.Response) (pipeline.Response, error) { + err := validateResponse(resp, http.StatusOK) + if resp == nil { + return nil, err + } + result := &ListResponse{rawResponse: resp.Response()} + if err != nil { + return result, err + } + defer resp.Response().Body.Close() + b, err := ioutil.ReadAll(resp.Response().Body) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to read response body") + } + if len(b) > 0 { + err = json.Unmarshal(b, &result.Value) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to unmarshal response body") + } + } + return result, nil +} diff --git a/services/appinsights/mgmt/2015-05-01/insights/marshalling.go b/services/appinsights/mgmt/2015-05-01/insights/marshalling.go new file mode 100644 index 000000000000..c3c0421b87b5 --- /dev/null +++ b/services/appinsights/mgmt/2015-05-01/insights/marshalling.go @@ -0,0 +1,98 @@ +package insights + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "encoding/xml" + "reflect" + "time" + "unsafe" +) + +const ( + rfc3339Format = "2006-01-02T15:04:05.0000000Z07:00" +) + +// used to convert times from UTC to GMT before sending across the wire +var gmt = time.FixedZone("GMT", 0) + +// internal type used for marshalling time in RFC1123 format +type timeRFC1123 struct { + time.Time +} + +// MarshalText implements the encoding.TextMarshaler interface for timeRFC1123. +func (t timeRFC1123) MarshalText() ([]byte, error) { + return []byte(t.Format(time.RFC1123)), nil +} + +// UnmarshalText implements the encoding.TextUnmarshaler interface for timeRFC1123. +func (t *timeRFC1123) UnmarshalText(data []byte) (err error) { + t.Time, err = time.Parse(time.RFC1123, string(data)) + return +} + +// internal type used for marshalling time in RFC3339 format +type timeRFC3339 struct { + time.Time +} + +// MarshalText implements the encoding.TextMarshaler interface for timeRFC3339. +func (t timeRFC3339) MarshalText() ([]byte, error) { + return []byte(t.Format(rfc3339Format)), nil +} + +// UnmarshalText implements the encoding.TextUnmarshaler interface for timeRFC3339. +func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { + t.Time, err = time.Parse(rfc3339Format, string(data)) + return +} + +// internal type used for marshalling +type applicationInsightsComponentProperties struct { + ApplicationID *string `json:"ApplicationId,omitempty"` + AppID *string `json:"AppId,omitempty"` + ApplicationType ApplicationType `json:"Application_Type,omitempty"` + FlowType FlowType `json:"Flow_Type,omitempty"` + RequestSource RequestSourceType `json:"Request_Source,omitempty"` + InstrumentationKey *string `json:"InstrumentationKey,omitempty"` + CreationDate *timeRFC3339 `json:"CreationDate,omitempty"` + TenantID *string `json:"TenantId,omitempty"` + HockeyAppID *string `json:"HockeyAppId,omitempty"` + HockeyAppToken *string `json:"HockeyAppToken,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + SamplingPercentage *float64 `json:"SamplingPercentage,omitempty"` +} + +// MarshalXML implements the xml.Marshaler interface for ApplicationInsightsComponentProperties. +func (aicp ApplicationInsightsComponentProperties) MarshalXML(e *xml.Encoder, start xml.StartElement) error { + if reflect.TypeOf((*ApplicationInsightsComponentProperties)(nil)).Elem().Size() != reflect.TypeOf((*applicationInsightsComponentProperties)(nil)).Elem().Size() { + panic("size mismatch between ApplicationInsightsComponentProperties and applicationInsightsComponentProperties") + } + aicp2 := (*applicationInsightsComponentProperties)(unsafe.Pointer(&aicp)) + return e.EncodeElement(*aicp2, start) +} + +// UnmarshalXML implements the xml.Unmarshaler interface for ApplicationInsightsComponentProperties. +func (aicp *ApplicationInsightsComponentProperties) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { + if reflect.TypeOf((*ApplicationInsightsComponentProperties)(nil)).Elem().Size() != reflect.TypeOf((*applicationInsightsComponentProperties)(nil)).Elem().Size() { + panic("size mismatch between ApplicationInsightsComponentProperties and applicationInsightsComponentProperties") + } + aicp2 := (*applicationInsightsComponentProperties)(unsafe.Pointer(aicp)) + return d.DecodeElement(aicp2, &start) +} diff --git a/services/appinsights/mgmt/2015-05-01/insights/models.go b/services/appinsights/mgmt/2015-05-01/insights/models.go index 4ad8e8c61434..683c6d3ce6ea 100644 --- a/services/appinsights/mgmt/2015-05-01/insights/models.go +++ b/services/appinsights/mgmt/2015-05-01/insights/models.go @@ -18,62 +18,124 @@ package insights // Changes may cause incorrect behavior and will be lost if the code is regenerated. import ( - "encoding/json" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/date" - "github.com/Azure/go-autorest/autorest/to" "net/http" + "time" ) +// Marker represents an opaque value used in paged responses. +type Marker struct { + val *string +} + +// NotDone returns true if the list enumeration should be started or is not yet complete. Specifically, NotDone returns true +// for a just-initialized (zero value) Marker indicating that you should make an initial request to get a result portion from +// the service. NotDone also returns true whenever the service returns an interim result portion. NotDone returns false only +// after the service has returned the final result portion. +func (m Marker) NotDone() bool { + return m.val == nil || *m.val != "" +} + +// UnmarshalXML implements the xml.Unmarshaler interface for Marker. +func (m *Marker) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { + var out string + err := d.DecodeElement(&out, &start) + m.val = &out + return err +} + // ApplicationType enumerates the values for application type. type ApplicationType string const ( - // Other ... - Other ApplicationType = "other" - // Web ... - Web ApplicationType = "web" + // ApplicationNone represents an empty ApplicationType. + ApplicationNone ApplicationType = "" + // ApplicationOther ... + ApplicationOther ApplicationType = "other" + // ApplicationWeb ... + ApplicationWeb ApplicationType = "web" +) + +// FavoriteSourceType enumerates the values for favorite source type. +type FavoriteSourceType string + +const ( + // FavoriteSourceEvents ... + FavoriteSourceEvents FavoriteSourceType = "events" + // FavoriteSourceFunnel ... + FavoriteSourceFunnel FavoriteSourceType = "funnel" + // FavoriteSourceImpact ... + FavoriteSourceImpact FavoriteSourceType = "impact" + // FavoriteSourceNone represents an empty FavoriteSourceType. + FavoriteSourceNone FavoriteSourceType = "" + // FavoriteSourceNotebook ... + FavoriteSourceNotebook FavoriteSourceType = "notebook" + // FavoriteSourceRetention ... + FavoriteSourceRetention FavoriteSourceType = "retention" + // FavoriteSourceSegmentation ... + FavoriteSourceSegmentation FavoriteSourceType = "segmentation" + // FavoriteSourceSessions ... + FavoriteSourceSessions FavoriteSourceType = "sessions" + // FavoriteSourceUserflows ... + FavoriteSourceUserflows FavoriteSourceType = "userflows" +) + +// FavoriteType enumerates the values for favorite type. +type FavoriteType string + +const ( + // FavoriteNone represents an empty FavoriteType. + FavoriteNone FavoriteType = "" + // FavoriteShared ... + FavoriteShared FavoriteType = "shared" + // FavoriteUser ... + FavoriteUser FavoriteType = "user" ) // FlowType enumerates the values for flow type. type FlowType string const ( - // Bluefield ... - Bluefield FlowType = "Bluefield" + // FlowBluefield ... + FlowBluefield FlowType = "Bluefield" + // FlowNone represents an empty FlowType. + FlowNone FlowType = "" ) -// RequestSource enumerates the values for request source. -type RequestSource string +// RequestSourceType enumerates the values for request source. +type RequestSourceType string const ( - // Rest ... - Rest RequestSource = "rest" + // RequestSourceNone represents an empty RequestSourceType. + RequestSourceNone RequestSourceType = "" + // RequestSourceRest ... + RequestSourceRest RequestSourceType = "rest" ) -// WebTestKind enumerates the values for web test kind. -type WebTestKind string +// WebTestKindType enumerates the values for web test kind. +type WebTestKindType string const ( - // Multistep ... - Multistep WebTestKind = "multistep" - // Ping ... - Ping WebTestKind = "ping" + // WebTestKindMultistep ... + WebTestKindMultistep WebTestKindType = "multistep" + // WebTestKindNone represents an empty WebTestKindType. + WebTestKindNone WebTestKindType = "" + // WebTestKindPing ... + WebTestKindPing WebTestKindType = "ping" ) -// APIKeyRequest an Application Insights component API Key createion request definition. +// APIKeyRequest - An Application Insights component API Key createion request definition. type APIKeyRequest struct { // Name - The name of the API Key. Name *string `json:"name,omitempty"` // LinkedReadProperties - The read access rights of this API Key. - LinkedReadProperties *[]string `json:"linkedReadProperties,omitempty"` + LinkedReadProperties []string `json:"linkedReadProperties,omitempty"` // LinkedWriteProperties - The write access rights of this API Key. - LinkedWriteProperties *[]string `json:"linkedWriteProperties,omitempty"` + LinkedWriteProperties []string `json:"linkedWriteProperties,omitempty"` } -// ApplicationInsightsComponent an Application Insights component definition. +// ApplicationInsightsComponent - An Application Insights component definition. type ApplicationInsightsComponent struct { - autorest.Response `json:"-"` + rawResponse *http.Response // ID - Azure resource Id ID *string `json:"id,omitempty"` // Name - Azure resource name @@ -81,100 +143,33 @@ type ApplicationInsightsComponent struct { // Type - Azure resource type Type *string `json:"type,omitempty"` // Location - Resource location - Location *string `json:"location,omitempty"` + Location string `json:"location,omitempty"` // Tags - Resource tags - Tags *map[string]*string `json:"tags,omitempty"` + Tags map[string]string `json:"tags,omitempty"` // Kind - The kind of application that this component refers to, used to customize UI. This value is a freeform string, values should typically be one of the following: web, ios, other, store, java, phone. - Kind *string `json:"kind,omitempty"` - // ApplicationInsightsComponentProperties - Properties that define an Application Insights component resource. + Kind string `json:"kind,omitempty"` + // Properties - Properties that define an Application Insights component resource. *ApplicationInsightsComponentProperties `json:"properties,omitempty"` } -// UnmarshalJSON is the custom unmarshaler for ApplicationInsightsComponent struct. -func (aic *ApplicationInsightsComponent) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - var v *json.RawMessage - - v = m["kind"] - if v != nil { - var kind string - err = json.Unmarshal(*m["kind"], &kind) - if err != nil { - return err - } - aic.Kind = &kind - } - - v = m["properties"] - if v != nil { - var properties ApplicationInsightsComponentProperties - err = json.Unmarshal(*m["properties"], &properties) - if err != nil { - return err - } - aic.ApplicationInsightsComponentProperties = &properties - } - - v = m["id"] - if v != nil { - var ID string - err = json.Unmarshal(*m["id"], &ID) - if err != nil { - return err - } - aic.ID = &ID - } - - v = m["name"] - if v != nil { - var name string - err = json.Unmarshal(*m["name"], &name) - if err != nil { - return err - } - aic.Name = &name - } - - v = m["type"] - if v != nil { - var typeVar string - err = json.Unmarshal(*m["type"], &typeVar) - if err != nil { - return err - } - aic.Type = &typeVar - } - - v = m["location"] - if v != nil { - var location string - err = json.Unmarshal(*m["location"], &location) - if err != nil { - return err - } - aic.Location = &location - } - - v = m["tags"] - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*m["tags"], &tags) - if err != nil { - return err - } - aic.Tags = &tags - } - - return nil -} - -// ApplicationInsightsComponentAPIKey properties that define an API key of an Application Insights Component. +// Response returns the raw HTTP response object. +func (aic ApplicationInsightsComponent) Response() *http.Response { + return aic.rawResponse +} + +// StatusCode returns the HTTP status code of the response, e.g. 200. +func (aic ApplicationInsightsComponent) StatusCode() int { + return aic.rawResponse.StatusCode +} + +// Status returns the HTTP status message of the response, e.g. "200 OK". +func (aic ApplicationInsightsComponent) Status() string { + return aic.rawResponse.Status +} + +// ApplicationInsightsComponentAPIKey - Properties that define an API key of an Application Insights Component. type ApplicationInsightsComponentAPIKey struct { - autorest.Response `json:"-"` + rawResponse *http.Response // ID - The unique ID of the API key inside an Applciation Insights component. It is auto generated when the API key is created. ID *string `json:"id,omitempty"` // APIKey - The API key value. It will be only return once when the API Key was created. @@ -184,28 +179,95 @@ type ApplicationInsightsComponentAPIKey struct { // Name - The name of the API key. Name *string `json:"name,omitempty"` // LinkedReadProperties - The read access rights of this API Key. - LinkedReadProperties *[]string `json:"linkedReadProperties,omitempty"` + LinkedReadProperties []string `json:"linkedReadProperties,omitempty"` // LinkedWriteProperties - The write access rights of this API Key. - LinkedWriteProperties *[]string `json:"linkedWriteProperties,omitempty"` + LinkedWriteProperties []string `json:"linkedWriteProperties,omitempty"` } -// ApplicationInsightsComponentAPIKeyListResult describes the list of API Keys of an Application Insights Component. +// Response returns the raw HTTP response object. +func (aicak ApplicationInsightsComponentAPIKey) Response() *http.Response { + return aicak.rawResponse +} + +// StatusCode returns the HTTP status code of the response, e.g. 200. +func (aicak ApplicationInsightsComponentAPIKey) StatusCode() int { + return aicak.rawResponse.StatusCode +} + +// Status returns the HTTP status message of the response, e.g. "200 OK". +func (aicak ApplicationInsightsComponentAPIKey) Status() string { + return aicak.rawResponse.Status +} + +// ApplicationInsightsComponentAPIKeyListResult - Describes the list of API Keys of an Application Insights Component. type ApplicationInsightsComponentAPIKeyListResult struct { - autorest.Response `json:"-"` + rawResponse *http.Response // Value - List of API Key definitions. - Value *[]ApplicationInsightsComponentAPIKey `json:"value,omitempty"` + Value []ApplicationInsightsComponentAPIKey `json:"value,omitempty"` +} + +// Response returns the raw HTTP response object. +func (aicaklr ApplicationInsightsComponentAPIKeyListResult) Response() *http.Response { + return aicaklr.rawResponse +} + +// StatusCode returns the HTTP status code of the response, e.g. 200. +func (aicaklr ApplicationInsightsComponentAPIKeyListResult) StatusCode() int { + return aicaklr.rawResponse.StatusCode +} + +// Status returns the HTTP status message of the response, e.g. "200 OK". +func (aicaklr ApplicationInsightsComponentAPIKeyListResult) Status() string { + return aicaklr.rawResponse.Status +} + +// ApplicationInsightsComponentAvailableFeatures - An Application Insights component available features. +type ApplicationInsightsComponentAvailableFeatures struct { + rawResponse *http.Response + // Result - A list of Application Insigths component feature. + Result []ApplicationInsightsComponentFeature `json:"Result,omitempty"` +} + +// Response returns the raw HTTP response object. +func (aicaf ApplicationInsightsComponentAvailableFeatures) Response() *http.Response { + return aicaf.rawResponse +} + +// StatusCode returns the HTTP status code of the response, e.g. 200. +func (aicaf ApplicationInsightsComponentAvailableFeatures) StatusCode() int { + return aicaf.rawResponse.StatusCode +} + +// Status returns the HTTP status message of the response, e.g. "200 OK". +func (aicaf ApplicationInsightsComponentAvailableFeatures) Status() string { + return aicaf.rawResponse.Status } -// ApplicationInsightsComponentBillingFeatures an Application Insights component billing features +// ApplicationInsightsComponentBillingFeatures - An Application Insights component billing features type ApplicationInsightsComponentBillingFeatures struct { - autorest.Response `json:"-"` + rawResponse *http.Response // DataVolumeCap - An Application Insights component daily data volumne cap DataVolumeCap *ApplicationInsightsComponentDataVolumeCap `json:"DataVolumeCap,omitempty"` // CurrentBillingFeatures - Current enabled pricing plan. When the component is in the Enterprise plan, this will list both 'Basic' and 'Application Insights Enterprise'. - CurrentBillingFeatures *[]string `json:"CurrentBillingFeatures,omitempty"` + CurrentBillingFeatures []string `json:"CurrentBillingFeatures,omitempty"` +} + +// Response returns the raw HTTP response object. +func (aicbf ApplicationInsightsComponentBillingFeatures) Response() *http.Response { + return aicbf.rawResponse +} + +// StatusCode returns the HTTP status code of the response, e.g. 200. +func (aicbf ApplicationInsightsComponentBillingFeatures) StatusCode() int { + return aicbf.rawResponse.StatusCode } -// ApplicationInsightsComponentDataVolumeCap an Application Insights component daily data volumne cap +// Status returns the HTTP status message of the response, e.g. "200 OK". +func (aicbf ApplicationInsightsComponentBillingFeatures) Status() string { + return aicbf.rawResponse.Status +} + +// ApplicationInsightsComponentDataVolumeCap - An Application Insights component daily data volumne cap type ApplicationInsightsComponentDataVolumeCap struct { // Cap - Daily data volume cap in GB. Cap *float64 `json:"Cap,omitempty"` @@ -221,9 +283,9 @@ type ApplicationInsightsComponentDataVolumeCap struct { MaxHistoryCap *float64 `json:"MaxHistoryCap,omitempty"` } -// ApplicationInsightsComponentExportConfiguration properties that define a Continuous Export configuration. +// ApplicationInsightsComponentExportConfiguration - Properties that define a Continuous Export configuration. type ApplicationInsightsComponentExportConfiguration struct { - autorest.Response `json:"-"` + rawResponse *http.Response // ExportID - The unique ID of the export configuration inside an Applciation Insights component. It is auto generated when the Continuous Export configuration is created. ExportID *string `json:"ExportId,omitempty"` // InstrumentationKey - The instrumentation key of the Application Insights component. @@ -264,8 +326,23 @@ type ApplicationInsightsComponentExportConfiguration struct { ContainerName *string `json:"ContainerName,omitempty"` } -// ApplicationInsightsComponentExportRequest an Application Insights component Continuous Export configuration request -// definition. +// Response returns the raw HTTP response object. +func (aicec ApplicationInsightsComponentExportConfiguration) Response() *http.Response { + return aicec.rawResponse +} + +// StatusCode returns the HTTP status code of the response, e.g. 200. +func (aicec ApplicationInsightsComponentExportConfiguration) StatusCode() int { + return aicec.rawResponse.StatusCode +} + +// Status returns the HTTP status message of the response, e.g. "200 OK". +func (aicec ApplicationInsightsComponentExportConfiguration) Status() string { + return aicec.rawResponse.Status +} + +// ApplicationInsightsComponentExportRequest - An Application Insights component Continuous Export configuration +// request definition. type ApplicationInsightsComponentExportRequest struct { // RecordTypes - The document types to be exported, as comma separated values. Allowed values include 'Requests', 'Event', 'Exceptions', 'Metrics', 'PageViews', 'PageViewPerformance', 'Rdd', 'PerformanceCounters', 'Availability', 'Messages'. RecordTypes *string `json:"RecordTypes,omitempty"` @@ -287,125 +364,233 @@ type ApplicationInsightsComponentExportRequest struct { DestinationAccountID *string `json:"DestinationAccountId,omitempty"` } -// ApplicationInsightsComponentListResult describes the list of Application Insights Resources. +// ApplicationInsightsComponentFavorite - Properties that define a favorite that is associated to an Application +// Insights component. +type ApplicationInsightsComponentFavorite struct { + rawResponse *http.Response + // Name - The user-defined name of the favorite. + Name *string `json:"Name,omitempty"` + // Config - Configuration of this particular favorite, which are driven by the Azure portal UX. Configuration data is a string containing valid JSON + Config *string `json:"Config,omitempty"` + // Version - This instance's version of the data model. This can change as new features are added that can be marked favorite. Current examples include MetricsExplorer (ME) and Search. + Version *string `json:"Version,omitempty"` + // FavoriteID - Internally assigned unique id of the favorite definition. + FavoriteID *string `json:"FavoriteId,omitempty"` + // FavoriteType - Enum indicating if this favorite definition is owned by a specific user or is shared between all users with access to the Application Insights component. Possible values include: 'Shared', 'User', 'None' + FavoriteType FavoriteType `json:"FavoriteType,omitempty"` + // SourceType - The source of the favorite definition. + SourceType *string `json:"SourceType,omitempty"` + // TimeModified - Date and time in UTC of the last modification that was made to this favorite definition. + TimeModified *string `json:"TimeModified,omitempty"` + // Tags - A list of 0 or more tags that are associated with this favorite definition + Tags []string `json:"Tags,omitempty"` + // Category - Favorite category, as defined by the user at creation time. + Category *string `json:"Category,omitempty"` + // IsGeneratedFromTemplate - Flag denoting wether or not this favorite was generated from a template. + IsGeneratedFromTemplate *bool `json:"IsGeneratedFromTemplate,omitempty"` + // UserID - Unique user id of the specific user that owns this favorite. + UserID *string `json:"UserId,omitempty"` +} + +// Response returns the raw HTTP response object. +func (aicf ApplicationInsightsComponentFavorite) Response() *http.Response { + return aicf.rawResponse +} + +// StatusCode returns the HTTP status code of the response, e.g. 200. +func (aicf ApplicationInsightsComponentFavorite) StatusCode() int { + return aicf.rawResponse.StatusCode +} + +// Status returns the HTTP status message of the response, e.g. "200 OK". +func (aicf ApplicationInsightsComponentFavorite) Status() string { + return aicf.rawResponse.Status +} + +// ApplicationInsightsComponentFeature - An Application Insights component daily data volume cap status +type ApplicationInsightsComponentFeature struct { + // FeatureName - The pricing feature name. + FeatureName *string `json:"FeatureName,omitempty"` + // MeterID - The meter id used for the feature. + MeterID *string `json:"MeterId,omitempty"` + // MeterRateFrequency - The meter meter rate for the feature's meter. + MeterRateFrequency *string `json:"MeterRateFrequency,omitempty"` + // ResouceID - Reserved, not used now. + ResouceID *string `json:"ResouceId,omitempty"` + // IsHidden - Reserved, not used now. + IsHidden *bool `json:"IsHidden,omitempty"` + // Capabilities - A list of Application Insigths component feature capability. + Capabilities []ApplicationInsightsComponentFeatureCapability `json:"Capabilities,omitempty"` + // Title - Desplay name of the feature. + Title *string `json:"Title,omitempty"` + // IsMainFeature - Whether can apply addon feature on to it. + IsMainFeature *bool `json:"IsMainFeature,omitempty"` + // SupportedAddonFeatures - The add on features on main feature. + SupportedAddonFeatures *string `json:"SupportedAddonFeatures,omitempty"` +} + +// ApplicationInsightsComponentFeatureCapabilities - An Application Insights component feature capabilities +type ApplicationInsightsComponentFeatureCapabilities struct { + rawResponse *http.Response + // SupportExportData - Whether allow to use continuous export feature. + SupportExportData *bool `json:"SupportExportData,omitempty"` + // BurstThrottlePolicy - Reserved, not used now. + BurstThrottlePolicy *string `json:"BurstThrottlePolicy,omitempty"` + // MetadataClass - Reserved, not used now. + MetadataClass *string `json:"MetadataClass,omitempty"` + // LiveStreamMetrics - Reserved, not used now. + LiveStreamMetrics *bool `json:"LiveStreamMetrics,omitempty"` + // ApplicationMap - Reserved, not used now. + ApplicationMap *bool `json:"ApplicationMap,omitempty"` + // WorkItemIntegration - Whether allow to use work item integration feature. + WorkItemIntegration *bool `json:"WorkItemIntegration,omitempty"` + // PowerBIIntegration - Reserved, not used now. + PowerBIIntegration *bool `json:"PowerBIIntegration,omitempty"` + // OpenSchema - Reserved, not used now. + OpenSchema *bool `json:"OpenSchema,omitempty"` + // ProactiveDetection - Reserved, not used now. + ProactiveDetection *bool `json:"ProactiveDetection,omitempty"` + // AnalyticsIntegration - Reserved, not used now. + AnalyticsIntegration *bool `json:"AnalyticsIntegration,omitempty"` + // MultipleStepWebTest - Whether allow to use multiple steps web test feature. + MultipleStepWebTest *bool `json:"MultipleStepWebTest,omitempty"` + // APIAccessLevel - Reserved, not used now. + APIAccessLevel *string `json:"ApiAccessLevel,omitempty"` + // TrackingType - The applciation insights component used tracking type. + TrackingType *string `json:"TrackingType,omitempty"` + // DailyCap - Daily data volume cap in GB. + DailyCap *float64 `json:"DailyCap,omitempty"` + // DailyCapResetTime - Daily data volume cap UTC reset hour. + DailyCapResetTime *float64 `json:"DailyCapResetTime,omitempty"` + // ThrottleRate - Reserved, not used now. + ThrottleRate *float64 `json:"ThrottleRate,omitempty"` +} + +// Response returns the raw HTTP response object. +func (aicfc ApplicationInsightsComponentFeatureCapabilities) Response() *http.Response { + return aicfc.rawResponse +} + +// StatusCode returns the HTTP status code of the response, e.g. 200. +func (aicfc ApplicationInsightsComponentFeatureCapabilities) StatusCode() int { + return aicfc.rawResponse.StatusCode +} + +// Status returns the HTTP status message of the response, e.g. "200 OK". +func (aicfc ApplicationInsightsComponentFeatureCapabilities) Status() string { + return aicfc.rawResponse.Status +} + +// ApplicationInsightsComponentFeatureCapability - An Application Insights component feature capability +type ApplicationInsightsComponentFeatureCapability struct { + // Name - The name of the capability. + Name *string `json:"Name,omitempty"` + // Description - The description of the capability. + Description *string `json:"Description,omitempty"` + // Value - The vaule of the capability. + Value *string `json:"Value,omitempty"` + // Unit - The unit of the capability. + Unit *string `json:"Unit,omitempty"` + // MeterID - The meter used for the capability. + MeterID *string `json:"MeterId,omitempty"` + // MeterRateFrequency - The meter rate of the meter. + MeterRateFrequency *string `json:"MeterRateFrequency,omitempty"` +} + +// ApplicationInsightsComponentListResult - Describes the list of Application Insights Resources. type ApplicationInsightsComponentListResult struct { - autorest.Response `json:"-"` + rawResponse *http.Response // Value - List of Application Insights component definitions. - Value *[]ApplicationInsightsComponent `json:"value,omitempty"` + Value []ApplicationInsightsComponent `json:"value,omitempty"` // NextLink - The URI to get the next set of Application Insights component defintions if too many components where returned in the result set. - NextLink *string `json:"nextLink,omitempty"` + NextLink Marker `json:"NextLink"` } -// ApplicationInsightsComponentListResultIterator provides access to a complete listing of ApplicationInsightsComponent -// values. -type ApplicationInsightsComponentListResultIterator struct { - i int - page ApplicationInsightsComponentListResultPage +// Response returns the raw HTTP response object. +func (aiclr ApplicationInsightsComponentListResult) Response() *http.Response { + return aiclr.rawResponse } -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *ApplicationInsightsComponentListResultIterator) Next() error { - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err := iter.page.Next() - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil +// StatusCode returns the HTTP status code of the response, e.g. 200. +func (aiclr ApplicationInsightsComponentListResult) StatusCode() int { + return aiclr.rawResponse.StatusCode } -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter ApplicationInsightsComponentListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) +// Status returns the HTTP status message of the response, e.g. "200 OK". +func (aiclr ApplicationInsightsComponentListResult) Status() string { + return aiclr.rawResponse.Status } -// Response returns the raw server response from the last page request. -func (iter ApplicationInsightsComponentListResultIterator) Response() ApplicationInsightsComponentListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter ApplicationInsightsComponentListResultIterator) Value() ApplicationInsightsComponent { - if !iter.page.NotDone() { - return ApplicationInsightsComponent{} - } - return iter.page.Values()[iter.i] -} - -// IsEmpty returns true if the ListResult contains no values. -func (aiclr ApplicationInsightsComponentListResult) IsEmpty() bool { - return aiclr.Value == nil || len(*aiclr.Value) == 0 -} - -// applicationInsightsComponentListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (aiclr ApplicationInsightsComponentListResult) applicationInsightsComponentListResultPreparer() (*http.Request, error) { - if aiclr.NextLink == nil || len(to.String(aiclr.NextLink)) < 1 { - return nil, nil - } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(aiclr.NextLink))) -} - -// ApplicationInsightsComponentListResultPage contains a page of ApplicationInsightsComponent values. -type ApplicationInsightsComponentListResultPage struct { - fn func(ApplicationInsightsComponentListResult) (ApplicationInsightsComponentListResult, error) - aiclr ApplicationInsightsComponentListResult -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *ApplicationInsightsComponentListResultPage) Next() error { - next, err := page.fn(page.aiclr) - if err != nil { - return err - } - page.aiclr = next - return nil +// ApplicationInsightsComponentProactiveDetectionConfiguration - Properties that define a ProactiveDetection +// configuration. +type ApplicationInsightsComponentProactiveDetectionConfiguration struct { + rawResponse *http.Response + // Name - The rule name + Name *string `json:"Name,omitempty"` + // Enabled - A flag that indicates whether this rule is enabled by the user + Enabled *bool `json:"Enabled,omitempty"` + // SendEmailsToSubscriptionOwners - A flag that indicated whether notifications on this rule should be sent to subscription owners + SendEmailsToSubscriptionOwners *bool `json:"SendEmailsToSubscriptionOwners,omitempty"` + // CustomEmails - Custom email addresses for this rule notifications + CustomEmails []string `json:"CustomEmails,omitempty"` + // LastUpdatedTime - The last time this rule was updated + LastUpdatedTime *string `json:"LastUpdatedTime,omitempty"` + // RuleDefinitions - Static definitions of the ProactiveDetection configuration rule (same values for all components). + RuleDefinitions *ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions `json:"RuleDefinitions,omitempty"` } -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page ApplicationInsightsComponentListResultPage) NotDone() bool { - return !page.aiclr.IsEmpty() +// Response returns the raw HTTP response object. +func (aicpdc ApplicationInsightsComponentProactiveDetectionConfiguration) Response() *http.Response { + return aicpdc.rawResponse } -// Response returns the raw server response from the last page request. -func (page ApplicationInsightsComponentListResultPage) Response() ApplicationInsightsComponentListResult { - return page.aiclr +// StatusCode returns the HTTP status code of the response, e.g. 200. +func (aicpdc ApplicationInsightsComponentProactiveDetectionConfiguration) StatusCode() int { + return aicpdc.rawResponse.StatusCode } -// Values returns the slice of values for the current page or nil if there are no values. -func (page ApplicationInsightsComponentListResultPage) Values() []ApplicationInsightsComponent { - if page.aiclr.IsEmpty() { - return nil - } - return *page.aiclr.Value +// Status returns the HTTP status message of the response, e.g. "200 OK". +func (aicpdc ApplicationInsightsComponentProactiveDetectionConfiguration) Status() string { + return aicpdc.rawResponse.Status } -// ApplicationInsightsComponentProperties properties that define an Application Insights component resource. +// ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions - Static definitions of the +// ProactiveDetection configuration rule (same values for all components). +type ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions struct { + // Name - The rule name + Name *string `json:"Name,omitempty"` + // DisplayName - The rule name as it is displayed in UI + DisplayName *string `json:"DisplayName,omitempty"` + // Description - The rule description + Description *string `json:"Description,omitempty"` + // HelpURL - URL which displays aditional info about the proactive detection rule + HelpURL *string `json:"HelpUrl,omitempty"` + // IsHidden - A flag indicating whether the rule is hidden (from the UI) + IsHidden *bool `json:"IsHidden,omitempty"` + // IsEnabledByDefault - A flag indicating whether the rule is enabled by default + IsEnabledByDefault *bool `json:"IsEnabledByDefault,omitempty"` + // IsInPreview - A flag indicating whether the rule is in preview + IsInPreview *bool `json:"IsInPreview,omitempty"` + // SupportsEmailNotifications - A flag indicating whether email notifications are supported for detections for this rule + SupportsEmailNotifications *bool `json:"SupportsEmailNotifications,omitempty"` +} + +// ApplicationInsightsComponentProperties - Properties that define an Application Insights component resource. type ApplicationInsightsComponentProperties struct { // ApplicationID - The unique ID of your application. This field mirrors the 'Name' field and cannot be changed. ApplicationID *string `json:"ApplicationId,omitempty"` // AppID - Application Insights Unique ID for your Application. AppID *string `json:"AppId,omitempty"` - // ApplicationType - Type of application being monitored. Possible values include: 'Web', 'Other' + // ApplicationType - Type of application being monitored. Possible values include: 'Web', 'Other', 'None' ApplicationType ApplicationType `json:"Application_Type,omitempty"` - // FlowType - Used by the Application Insights system to determine what kind of flow this component was created by. This is to be set to 'Bluefield' when creating/updating a component via the REST API. Possible values include: 'Bluefield' + // FlowType - Used by the Application Insights system to determine what kind of flow this component was created by. This is to be set to 'Bluefield' when creating/updating a component via the REST API. Possible values include: 'Bluefield', 'None' FlowType FlowType `json:"Flow_Type,omitempty"` - // RequestSource - Describes what tool created this Application Insights component. Customers using this API should set this to the default 'rest'. Possible values include: 'Rest' - RequestSource RequestSource `json:"Request_Source,omitempty"` + // RequestSource - Describes what tool created this Application Insights component. Customers using this API should set this to the default 'rest'. Possible values include: 'Rest', 'None' + RequestSource RequestSourceType `json:"Request_Source,omitempty"` // InstrumentationKey - Application Insights Instrumentation key. A read-only value that applications can use to identify the destination for all telemetry sent to Azure Application Insights. This value will be supplied upon construction of each new Application Insights component. InstrumentationKey *string `json:"InstrumentationKey,omitempty"` // CreationDate - Creation Date for the Application Insights component, in ISO 8601 format. - CreationDate *date.Time `json:"CreationDate,omitempty"` + CreationDate *time.Time `json:"CreationDate,omitempty"` // TenantID - Azure Tenant Id. TenantID *string `json:"TenantId,omitempty"` // HockeyAppID - The unique application ID created when a new application is added to HockeyApp, used for communications with HockeyApp. @@ -418,9 +603,9 @@ type ApplicationInsightsComponentProperties struct { SamplingPercentage *float64 `json:"SamplingPercentage,omitempty"` } -// ApplicationInsightsComponentQuotaStatus an Application Insights component daily data volume cap status +// ApplicationInsightsComponentQuotaStatus - An Application Insights component daily data volume cap status type ApplicationInsightsComponentQuotaStatus struct { - autorest.Response `json:"-"` + rawResponse *http.Response // AppID - The Application ID for the Application Insights component. AppID *string `json:"AppId,omitempty"` // ShouldBeThrottled - The daily data volume cap is met, and data ingestion will be stopped. @@ -429,7 +614,75 @@ type ApplicationInsightsComponentQuotaStatus struct { ExpirationTime *string `json:"ExpirationTime,omitempty"` } -// ErrorResponse error reponse indicates Insights service is not able to process the incoming request. The reason is +// Response returns the raw HTTP response object. +func (aicqs ApplicationInsightsComponentQuotaStatus) Response() *http.Response { + return aicqs.rawResponse +} + +// StatusCode returns the HTTP status code of the response, e.g. 200. +func (aicqs ApplicationInsightsComponentQuotaStatus) StatusCode() int { + return aicqs.rawResponse.StatusCode +} + +// Status returns the HTTP status message of the response, e.g. "200 OK". +func (aicqs ApplicationInsightsComponentQuotaStatus) Status() string { + return aicqs.rawResponse.Status +} + +// ApplicationInsightsComponentWebTestLocation - Properties that define a web test location available to an Application +// Insights Component. +type ApplicationInsightsComponentWebTestLocation struct { + // DisplayName - The display name of the web test location. + DisplayName *string `json:"DisplayName,omitempty"` + // Tag - Internally defined geographic location tag. + Tag *string `json:"Tag,omitempty"` +} + +// ApplicationInsightsWebTestLocationsListResult - Describes the list of web test locations available to an Application +// Insights Component. +type ApplicationInsightsWebTestLocationsListResult struct { + rawResponse *http.Response + // Value - List of web test locations. + Value []ApplicationInsightsComponentWebTestLocation `json:"value,omitempty"` +} + +// Response returns the raw HTTP response object. +func (aiwtllr ApplicationInsightsWebTestLocationsListResult) Response() *http.Response { + return aiwtllr.rawResponse +} + +// StatusCode returns the HTTP status code of the response, e.g. 200. +func (aiwtllr ApplicationInsightsWebTestLocationsListResult) StatusCode() int { + return aiwtllr.rawResponse.StatusCode +} + +// Status returns the HTTP status message of the response, e.g. "200 OK". +func (aiwtllr ApplicationInsightsWebTestLocationsListResult) Status() string { + return aiwtllr.rawResponse.Status +} + +// CreateResponse ... +type CreateResponse struct { + rawResponse *http.Response + Value []ApplicationInsightsComponentExportConfiguration `json:"value,omitempty"` +} + +// Response returns the raw HTTP response object. +func (cr CreateResponse) Response() *http.Response { + return cr.rawResponse +} + +// StatusCode returns the HTTP status code of the response, e.g. 200. +func (cr CreateResponse) StatusCode() int { + return cr.rawResponse.StatusCode +} + +// Status returns the HTTP status message of the response, e.g. "200 OK". +func (cr CreateResponse) Status() string { + return cr.rawResponse.Status +} + +// ErrorResponse - Error reponse indicates Insights service is not able to process the incoming request. The reason is // provided in the error message. type ErrorResponse struct { // Code - Error code. @@ -438,13 +691,28 @@ type ErrorResponse struct { Message *string `json:"message,omitempty"` } -// ListApplicationInsightsComponentExportConfiguration ... -type ListApplicationInsightsComponentExportConfiguration struct { - autorest.Response `json:"-"` - Value *[]ApplicationInsightsComponentExportConfiguration `json:"value,omitempty"` +// ListResponse ... +type ListResponse struct { + rawResponse *http.Response + Value []ApplicationInsightsComponentExportConfiguration `json:"value,omitempty"` +} + +// Response returns the raw HTTP response object. +func (lr ListResponse) Response() *http.Response { + return lr.rawResponse +} + +// StatusCode returns the HTTP status code of the response, e.g. 200. +func (lr ListResponse) StatusCode() int { + return lr.rawResponse.StatusCode +} + +// Status returns the HTTP status message of the response, e.g. "200 OK". +func (lr ListResponse) Status() string { + return lr.rawResponse.Status } -// Operation CDN REST API operation +// Operation - CDN REST API operation type Operation struct { // Name - Operation name: {provider}/{resource}/{operation} Name *string `json:"name,omitempty"` @@ -452,7 +720,7 @@ type Operation struct { Display *OperationDisplay `json:"display,omitempty"` } -// OperationDisplay the object that represents the operation. +// OperationDisplay - The object that represents the operation. type OperationDisplay struct { // Provider - Service provider: Microsoft.Cdn Provider *string `json:"provider,omitempty"` @@ -462,110 +730,32 @@ type OperationDisplay struct { Operation *string `json:"operation,omitempty"` } -// OperationListResult result of the request to list CDN operations. It contains a list of operations and a URL link to -// get the next set of results. +// OperationListResult - Result of the request to list CDN operations. It contains a list of operations and a URL link +// to get the next set of results. type OperationListResult struct { - autorest.Response `json:"-"` + rawResponse *http.Response // Value - List of CDN operations supported by the CDN resource provider. - Value *[]Operation `json:"value,omitempty"` + Value []Operation `json:"value,omitempty"` // NextLink - URL to get the next set of operation list results if there are any. - NextLink *string `json:"nextLink,omitempty"` -} - -// OperationListResultIterator provides access to a complete listing of Operation values. -type OperationListResultIterator struct { - i int - page OperationListResultPage -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *OperationListResultIterator) Next() error { - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err := iter.page.Next() - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter OperationListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter OperationListResultIterator) Response() OperationListResult { - return iter.page.Response() + NextLink Marker `json:"NextLink"` } -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter OperationListResultIterator) Value() Operation { - if !iter.page.NotDone() { - return Operation{} - } - return iter.page.Values()[iter.i] +// Response returns the raw HTTP response object. +func (olr OperationListResult) Response() *http.Response { + return olr.rawResponse } -// IsEmpty returns true if the ListResult contains no values. -func (olr OperationListResult) IsEmpty() bool { - return olr.Value == nil || len(*olr.Value) == 0 +// StatusCode returns the HTTP status code of the response, e.g. 200. +func (olr OperationListResult) StatusCode() int { + return olr.rawResponse.StatusCode } -// operationListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (olr OperationListResult) operationListResultPreparer() (*http.Request, error) { - if olr.NextLink == nil || len(to.String(olr.NextLink)) < 1 { - return nil, nil - } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(olr.NextLink))) +// Status returns the HTTP status message of the response, e.g. "200 OK". +func (olr OperationListResult) Status() string { + return olr.rawResponse.Status } -// OperationListResultPage contains a page of Operation values. -type OperationListResultPage struct { - fn func(OperationListResult) (OperationListResult, error) - olr OperationListResult -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *OperationListResultPage) Next() error { - next, err := page.fn(page.olr) - if err != nil { - return err - } - page.olr = next - return nil -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page OperationListResultPage) NotDone() bool { - return !page.olr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page OperationListResultPage) Response() OperationListResult { - return page.olr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page OperationListResultPage) Values() []Operation { - if page.olr.IsEmpty() { - return nil - } - return *page.olr.Value -} - -// Resource an azure resource object +// Resource - An azure resource object type Resource struct { // ID - Azure resource Id ID *string `json:"id,omitempty"` @@ -574,21 +764,21 @@ type Resource struct { // Type - Azure resource type Type *string `json:"type,omitempty"` // Location - Resource location - Location *string `json:"location,omitempty"` + Location string `json:"location,omitempty"` // Tags - Resource tags - Tags *map[string]*string `json:"tags,omitempty"` + Tags map[string]string `json:"tags,omitempty"` } -// TagsResource a container holding only the Tags for a resource, allowing the user to update the tags on a WebTest +// TagsResource - A container holding only the Tags for a resource, allowing the user to update the tags on a WebTest // instance. type TagsResource struct { // Tags - Resource tags - Tags *map[string]*string `json:"tags,omitempty"` + Tags map[string]string `json:"tags,omitempty"` } -// WebTest an Application Insights web test definition. +// WebTest - An Application Insights web test definition. type WebTest struct { - autorest.Response `json:"-"` + rawResponse *http.Response // ID - Azure resource Id ID *string `json:"id,omitempty"` // Name - Azure resource name @@ -596,212 +786,67 @@ type WebTest struct { // Type - Azure resource type Type *string `json:"type,omitempty"` // Location - Resource location - Location *string `json:"location,omitempty"` + Location string `json:"location,omitempty"` // Tags - Resource tags - Tags *map[string]*string `json:"tags,omitempty"` - // Kind - The kind of web test that this web test watches. Choices are ping and multistep. Possible values include: 'Ping', 'Multistep' - Kind WebTestKind `json:"kind,omitempty"` - // WebTestProperties - Metadata describing a web test for an Azure resource. + Tags map[string]string `json:"tags,omitempty"` + // Kind - The kind of web test that this web test watches. Choices are ping and multistep. Possible values include: 'Ping', 'Multistep', 'None' + Kind WebTestKindType `json:"kind,omitempty"` + // Properties - Metadata describing a web test for an Azure resource. *WebTestProperties `json:"properties,omitempty"` } -// UnmarshalJSON is the custom unmarshaler for WebTest struct. -func (wt *WebTest) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - var v *json.RawMessage - - v = m["kind"] - if v != nil { - var kind WebTestKind - err = json.Unmarshal(*m["kind"], &kind) - if err != nil { - return err - } - wt.Kind = kind - } - - v = m["properties"] - if v != nil { - var properties WebTestProperties - err = json.Unmarshal(*m["properties"], &properties) - if err != nil { - return err - } - wt.WebTestProperties = &properties - } - - v = m["id"] - if v != nil { - var ID string - err = json.Unmarshal(*m["id"], &ID) - if err != nil { - return err - } - wt.ID = &ID - } - - v = m["name"] - if v != nil { - var name string - err = json.Unmarshal(*m["name"], &name) - if err != nil { - return err - } - wt.Name = &name - } - - v = m["type"] - if v != nil { - var typeVar string - err = json.Unmarshal(*m["type"], &typeVar) - if err != nil { - return err - } - wt.Type = &typeVar - } - - v = m["location"] - if v != nil { - var location string - err = json.Unmarshal(*m["location"], &location) - if err != nil { - return err - } - wt.Location = &location - } - - v = m["tags"] - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*m["tags"], &tags) - if err != nil { - return err - } - wt.Tags = &tags - } - - return nil -} - -// WebTestGeolocation geo-physical location to run a web test from. You must specify one or more locations for the test -// to run from. -type WebTestGeolocation struct { - // Location - Location ID for the webtest to run from. - Location *string `json:"Id,omitempty"` -} - -// WebTestListResult a list of 0 or more Application Insights web test definitions. -type WebTestListResult struct { - autorest.Response `json:"-"` - // Value - Set of Application Insights web test definitions. - Value *[]WebTest `json:"value,omitempty"` - // NextLink - The link to get the next part of the returned list of web tests, should the return set be too large for a single request. May be null. - NextLink *string `json:"nextLink,omitempty"` -} - -// WebTestListResultIterator provides access to a complete listing of WebTest values. -type WebTestListResultIterator struct { - i int - page WebTestListResultPage -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *WebTestListResultIterator) Next() error { - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err := iter.page.Next() - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter WebTestListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter WebTestListResultIterator) Response() WebTestListResult { - return iter.page.Response() +// Response returns the raw HTTP response object. +func (wt WebTest) Response() *http.Response { + return wt.rawResponse } -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter WebTestListResultIterator) Value() WebTest { - if !iter.page.NotDone() { - return WebTest{} - } - return iter.page.Values()[iter.i] +// StatusCode returns the HTTP status code of the response, e.g. 200. +func (wt WebTest) StatusCode() int { + return wt.rawResponse.StatusCode } -// IsEmpty returns true if the ListResult contains no values. -func (wtlr WebTestListResult) IsEmpty() bool { - return wtlr.Value == nil || len(*wtlr.Value) == 0 +// Status returns the HTTP status message of the response, e.g. "200 OK". +func (wt WebTest) Status() string { + return wt.rawResponse.Status } -// webTestListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (wtlr WebTestListResult) webTestListResultPreparer() (*http.Request, error) { - if wtlr.NextLink == nil || len(to.String(wtlr.NextLink)) < 1 { - return nil, nil - } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(wtlr.NextLink))) -} - -// WebTestListResultPage contains a page of WebTest values. -type WebTestListResultPage struct { - fn func(WebTestListResult) (WebTestListResult, error) - wtlr WebTestListResult +// WebTestGeolocation - Geo-physical location to run a web test from. You must specify one or more locations for the +// test to run from. +type WebTestGeolocation struct { + // Location - Location ID for the webtest to run from. + Location *string `json:"Id,omitempty"` } -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *WebTestListResultPage) Next() error { - next, err := page.fn(page.wtlr) - if err != nil { - return err - } - page.wtlr = next - return nil +// WebTestListResult - A list of 0 or more Application Insights web test definitions. +type WebTestListResult struct { + rawResponse *http.Response + // Value - Set of Application Insights web test definitions. + Value []WebTest `json:"value,omitempty"` + // NextLink - The link to get the next part of the returned list of web tests, should the return set be too large for a single request. May be null. + NextLink Marker `json:"NextLink"` } -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page WebTestListResultPage) NotDone() bool { - return !page.wtlr.IsEmpty() +// Response returns the raw HTTP response object. +func (wtlr WebTestListResult) Response() *http.Response { + return wtlr.rawResponse } -// Response returns the raw server response from the last page request. -func (page WebTestListResultPage) Response() WebTestListResult { - return page.wtlr +// StatusCode returns the HTTP status code of the response, e.g. 200. +func (wtlr WebTestListResult) StatusCode() int { + return wtlr.rawResponse.StatusCode } -// Values returns the slice of values for the current page or nil if there are no values. -func (page WebTestListResultPage) Values() []WebTest { - if page.wtlr.IsEmpty() { - return nil - } - return *page.wtlr.Value +// Status returns the HTTP status message of the response, e.g. "200 OK". +func (wtlr WebTestListResult) Status() string { + return wtlr.rawResponse.Status } -// WebTestProperties metadata describing a web test for an Azure resource. +// WebTestProperties - Metadata describing a web test for an Azure resource. type WebTestProperties struct { // SyntheticMonitorID - Unique ID of this WebTest. This is typically the same value as the Name field. - SyntheticMonitorID *string `json:"SyntheticMonitorId,omitempty"` + SyntheticMonitorID string `json:"SyntheticMonitorId,omitempty"` // WebTestName - User defined name if this WebTest. - WebTestName *string `json:"Name,omitempty"` + WebTestName string `json:"Name,omitempty"` // Description - Purpose/user defined descriptive test for this WebTest. Description *string `json:"Description,omitempty"` // Enabled - Is the test actively being monitored. @@ -810,19 +855,19 @@ type WebTestProperties struct { Frequency *int32 `json:"Frequency,omitempty"` // Timeout - Seconds until this WebTest will timeout and fail. Default value is 30. Timeout *int32 `json:"Timeout,omitempty"` - // WebTestKind - The kind of web test this is, valid choices are ping and multistep. Possible values include: 'Ping', 'Multistep' - WebTestKind WebTestKind `json:"Kind,omitempty"` + // WebTestKind - The kind of web test this is, valid choices are ping and multistep. Possible values include: 'Ping', 'Multistep', 'None' + WebTestKind WebTestKindType `json:"Kind,omitempty"` // RetryEnabled - Allow for retries should this WebTest fail. RetryEnabled *bool `json:"RetryEnabled,omitempty"` // Locations - A list of where to physically run the tests from to give global coverage for accessibility of your application. - Locations *[]WebTestGeolocation `json:"Locations,omitempty"` + Locations []WebTestGeolocation `json:"Locations,omitempty"` // Configuration - An XML configuration specification for a WebTest. Configuration *WebTestPropertiesConfiguration `json:"Configuration,omitempty"` // ProvisioningState - Current state of this component, whether or not is has been provisioned within the resource group it is defined. Users cannot change this value but are able to read from it. Values will include Succeeded, Deploying, Canceled, and Failed. ProvisioningState *string `json:"provisioningState,omitempty"` } -// WebTestPropertiesConfiguration an XML configuration specification for a WebTest. +// WebTestPropertiesConfiguration - An XML configuration specification for a WebTest. type WebTestPropertiesConfiguration struct { // WebTest - The XML specification of a WebTest to run against an application. WebTest *string `json:"WebTest,omitempty"` diff --git a/services/appinsights/mgmt/2015-05-01/insights/operations.go b/services/appinsights/mgmt/2015-05-01/insights/operations.go index 5ec3ae1bedc8..67f5a77c43ac 100644 --- a/services/appinsights/mgmt/2015-05-01/insights/operations.go +++ b/services/appinsights/mgmt/2015-05-01/insights/operations.go @@ -19,108 +19,69 @@ package insights import ( "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" + "encoding/json" + "github.com/Azure/azure-pipeline-go/pipeline" + "io/ioutil" "net/http" ) // OperationsClient is the composite Swagger for Application Insights Management Client type OperationsClient struct { - BaseClient + ManagementClient } // NewOperationsClient creates an instance of the OperationsClient client. -func NewOperationsClient(subscriptionID string) OperationsClient { - return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client. -func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { - return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +func NewOperationsClient(p pipeline.Pipeline) OperationsClient { + return OperationsClient{NewManagementClient(p)} } // List lists all of the available insights REST API operations. -func (client OperationsClient) List(ctx context.Context) (result OperationListResultPage, err error) { - result.fn = client.listNextResults - req, err := client.ListPreparer(ctx) +func (client OperationsClient) List(ctx context.Context) (*OperationListResult, error) { + req, err := client.listPreparer() if err != nil { - err = autorest.NewErrorWithError(err, "insights.OperationsClient", "List", nil, "Failure preparing request") - return + return nil, err } - - resp, err := client.ListSender(req) + resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.listResponder}, req) if err != nil { - result.olr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "insights.OperationsClient", "List", resp, "Failure sending request") - return + return nil, err } + return resp.(*OperationListResult), err +} - result.olr, err = client.ListResponder(resp) +// listPreparer prepares the List request. +func (client OperationsClient) listPreparer() (pipeline.Request, error) { + u := client.url + u.Path = "/providers/microsoft.insights/operations" + req, err := pipeline.NewRequest("GET", u, nil) if err != nil { - err = autorest.NewErrorWithError(err, "insights.OperationsClient", "List", resp, "Failure responding to request") + return req, pipeline.NewError(err, "failed to create request") } - - return + params := req.URL.Query() + params.Set("api-version", APIVersion) + req.URL.RawQuery = params.Encode() + return req, nil } -// ListPreparer prepares the List request. -func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { - const APIVersion = "2015-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, +// listResponder handles the response to the List request. +func (client OperationsClient) listResponder(resp pipeline.Response) (pipeline.Response, error) { + err := validateResponse(resp, http.StatusOK) + if resp == nil { + return nil, err } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/providers/microsoft.insights/operations"), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listNextResults retrieves the next set of results, if any. -func (client OperationsClient) listNextResults(lastResults OperationListResult) (result OperationListResult, err error) { - req, err := lastResults.operationListResultPreparer() + result := &OperationListResult{rawResponse: resp.Response()} if err != nil { - return result, autorest.NewErrorWithError(err, "insights.OperationsClient", "listNextResults", nil, "Failure preparing next results request") + return result, err } - if req == nil { - return - } - resp, err := client.ListSender(req) + defer resp.Response().Body.Close() + b, err := ioutil.ReadAll(resp.Response().Body) if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "insights.OperationsClient", "listNextResults", resp, "Failure sending next results request") + return result, NewResponseError(err, resp.Response(), "failed to read response body") } - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.OperationsClient", "listNextResults", resp, "Failure responding to next results request") + if len(b) > 0 { + err = json.Unmarshal(b, result) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to unmarshal response body") + } } - return -} - -// ListComplete enumerates all values, automatically crossing page boundaries as required. -func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListResultIterator, err error) { - result.page, err = client.List(ctx) - return + return result, nil } diff --git a/services/appinsights/mgmt/2015-05-01/insights/proactive_detection_configurations.go b/services/appinsights/mgmt/2015-05-01/insights/proactive_detection_configurations.go new file mode 100644 index 000000000000..23a312487d9e --- /dev/null +++ b/services/appinsights/mgmt/2015-05-01/insights/proactive_detection_configurations.go @@ -0,0 +1,211 @@ +package insights + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "bytes" + "context" + "encoding/json" + "github.com/Azure/azure-pipeline-go/pipeline" + "io/ioutil" + "net/http" +) + +// ProactiveDetectionConfigurationsClient is the composite Swagger for Application Insights Management Client +type ProactiveDetectionConfigurationsClient struct { + ManagementClient +} + +// NewProactiveDetectionConfigurationsClient creates an instance of the ProactiveDetectionConfigurationsClient client. +func NewProactiveDetectionConfigurationsClient(p pipeline.Pipeline) ProactiveDetectionConfigurationsClient { + return ProactiveDetectionConfigurationsClient{NewManagementClient(p)} +} + +// Get get the ProactiveDetection configuration for this configuration id. +// +// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights component +// resource. configurationID is the ProactiveDetection configuration ID. This is unique within a Application Insights +// component. +func (client ProactiveDetectionConfigurationsClient) Get(ctx context.Context, resourceGroupName string, resourceName string, configurationID string) (*ApplicationInsightsComponentProactiveDetectionConfiguration, error) { + req, err := client.getPreparer(resourceGroupName, resourceName, configurationID) + if err != nil { + return nil, err + } + resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.getResponder}, req) + if err != nil { + return nil, err + } + return resp.(*ApplicationInsightsComponentProactiveDetectionConfiguration), err +} + +// getPreparer prepares the Get request. +func (client ProactiveDetectionConfigurationsClient) getPreparer(resourceGroupName string, resourceName string, configurationID string) (pipeline.Request, error) { + u := client.url + u.Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/ProactiveDetectionConfigs/{ConfigurationId}" + req, err := pipeline.NewRequest("GET", u, nil) + if err != nil { + return req, pipeline.NewError(err, "failed to create request") + } + params := req.URL.Query() + params.Set("api-version", APIVersion) + req.URL.RawQuery = params.Encode() + return req, nil +} + +// getResponder handles the response to the Get request. +func (client ProactiveDetectionConfigurationsClient) getResponder(resp pipeline.Response) (pipeline.Response, error) { + err := validateResponse(resp, http.StatusOK) + if resp == nil { + return nil, err + } + result := &ApplicationInsightsComponentProactiveDetectionConfiguration{rawResponse: resp.Response()} + if err != nil { + return result, err + } + defer resp.Response().Body.Close() + b, err := ioutil.ReadAll(resp.Response().Body) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to read response body") + } + if len(b) > 0 { + err = json.Unmarshal(b, result) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to unmarshal response body") + } + } + return result, nil +} + +// List gets a list of ProactiveDetection configurations of an Application Insights component. +// +// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights component +// resource. +func (client ProactiveDetectionConfigurationsClient) List(ctx context.Context, resourceGroupName string, resourceName string) (*ListResponse, error) { + req, err := client.listPreparer(resourceGroupName, resourceName) + if err != nil { + return nil, err + } + resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.listResponder}, req) + if err != nil { + return nil, err + } + return resp.(*ListResponse), err +} + +// listPreparer prepares the List request. +func (client ProactiveDetectionConfigurationsClient) listPreparer(resourceGroupName string, resourceName string) (pipeline.Request, error) { + u := client.url + u.Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/ProactiveDetectionConfigs" + req, err := pipeline.NewRequest("GET", u, nil) + if err != nil { + return req, pipeline.NewError(err, "failed to create request") + } + params := req.URL.Query() + params.Set("api-version", APIVersion) + req.URL.RawQuery = params.Encode() + return req, nil +} + +// listResponder handles the response to the List request. +func (client ProactiveDetectionConfigurationsClient) listResponder(resp pipeline.Response) (pipeline.Response, error) { + err := validateResponse(resp, http.StatusOK) + if resp == nil { + return nil, err + } + result := &ListResponse{rawResponse: resp.Response()} + if err != nil { + return result, err + } + defer resp.Response().Body.Close() + b, err := ioutil.ReadAll(resp.Response().Body) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to read response body") + } + if len(b) > 0 { + err = json.Unmarshal(b, &result.Value) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to unmarshal response body") + } + } + return result, nil +} + +// Update update the ProactiveDetection configuration for this configuration id. +// +// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights component +// resource. configurationID is the ProactiveDetection configuration ID. This is unique within a Application Insights +// component. proactiveDetectionProperties is properties that need to be specified to update the ProactiveDetection +// configuration. +func (client ProactiveDetectionConfigurationsClient) Update(ctx context.Context, resourceGroupName string, resourceName string, configurationID string, proactiveDetectionProperties ApplicationInsightsComponentProactiveDetectionConfiguration) (*ApplicationInsightsComponentProactiveDetectionConfiguration, error) { + req, err := client.updatePreparer(resourceGroupName, resourceName, configurationID, proactiveDetectionProperties) + if err != nil { + return nil, err + } + resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.updateResponder}, req) + if err != nil { + return nil, err + } + return resp.(*ApplicationInsightsComponentProactiveDetectionConfiguration), err +} + +// updatePreparer prepares the Update request. +func (client ProactiveDetectionConfigurationsClient) updatePreparer(resourceGroupName string, resourceName string, configurationID string, proactiveDetectionProperties ApplicationInsightsComponentProactiveDetectionConfiguration) (pipeline.Request, error) { + u := client.url + u.Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/ProactiveDetectionConfigs/{ConfigurationId}" + req, err := pipeline.NewRequest("PUT", u, nil) + if err != nil { + return req, pipeline.NewError(err, "failed to create request") + } + params := req.URL.Query() + params.Set("api-version", APIVersion) + req.URL.RawQuery = params.Encode() + b, err := json.Marshal(proactiveDetectionProperties) + if err != nil { + return req, pipeline.NewError(err, "failed to marshal request body") + } + req.Header.Set("Content-Type", "application/json") + err = req.SetBody(bytes.NewReader(b)) + if err != nil { + return req, pipeline.NewError(err, "failed to set request body") + } + return req, nil +} + +// updateResponder handles the response to the Update request. +func (client ProactiveDetectionConfigurationsClient) updateResponder(resp pipeline.Response) (pipeline.Response, error) { + err := validateResponse(resp, http.StatusOK) + if resp == nil { + return nil, err + } + result := &ApplicationInsightsComponentProactiveDetectionConfiguration{rawResponse: resp.Response()} + if err != nil { + return result, err + } + defer resp.Response().Body.Close() + b, err := ioutil.ReadAll(resp.Response().Body) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to read response body") + } + if len(b) > 0 { + err = json.Unmarshal(b, result) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to unmarshal response body") + } + } + return result, nil +} diff --git a/services/appinsights/mgmt/2015-05-01/insights/responder_policy.go b/services/appinsights/mgmt/2015-05-01/insights/responder_policy.go new file mode 100644 index 000000000000..80541fff9960 --- /dev/null +++ b/services/appinsights/mgmt/2015-05-01/insights/responder_policy.go @@ -0,0 +1,81 @@ +package insights + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "encoding/xml" + "github.com/Azure/azure-pipeline-go/pipeline" + "io/ioutil" +) + +type responder func(resp pipeline.Response) (result pipeline.Response, err error) + +// ResponderPolicyFactory is a Factory capable of creating a responder pipeline. +type responderPolicyFactory struct { + responder responder +} + +// New creates a responder policy factory. +func (arpf responderPolicyFactory) New(next pipeline.Policy, po *pipeline.PolicyOptions) pipeline.Policy { + return responderPolicy{next: next, responder: arpf.responder} +} + +type responderPolicy struct { + next pipeline.Policy + responder responder +} + +// Do sends the request to the service and validates/deserializes the HTTP response. +func (arp responderPolicy) Do(ctx context.Context, request pipeline.Request) (pipeline.Response, error) { + resp, err := arp.next.Do(ctx, request) + if err != nil { + return resp, err + } + return arp.responder(resp) +} + +// validateResponse checks an HTTP response's status code against a legal set of codes. +// If the response code is not legal, then validateResponse reads all of the response's body +// (containing error information) and returns a response error. +func validateResponse(resp pipeline.Response, successStatusCodes ...int) error { + if resp == nil { + return NewResponseError(nil, nil, "nil response") + } + responseCode := resp.Response().StatusCode + for _, i := range successStatusCodes { + if i == responseCode { + return nil + } + } + // only close the body in the failure case. in the + // success case responders will close the body as required. + defer resp.Response().Body.Close() + b, err := ioutil.ReadAll(resp.Response().Body) + if err != nil { + return NewResponseError(err, resp.Response(), "failed to read response body") + } + // the service code, description and details will be populated during unmarshalling + responseError := NewResponseError(nil, resp.Response(), resp.Response().Status) + if len(b) > 0 { + if err = xml.Unmarshal(b, &responseError); err != nil { + return NewResponseError(err, resp.Response(), "failed to unmarshal response body") + } + } + return responseError +} diff --git a/services/appinsights/mgmt/2015-05-01/insights/response_error.go b/services/appinsights/mgmt/2015-05-01/insights/response_error.go new file mode 100644 index 000000000000..0bb13d9cd68e --- /dev/null +++ b/services/appinsights/mgmt/2015-05-01/insights/response_error.go @@ -0,0 +1,110 @@ +package insights + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "bytes" + "fmt" + "github.com/Azure/azure-pipeline-go/pipeline" + "net" + "net/http" +) + +// if you want to provide custom error handling set this variable to your constructor function +var responseErrorFactory func(cause error, response *http.Response, description string) error + +// ResponseError identifies a responder-generated network or response parsing error. +type ResponseError interface { + // Error exposes the Error(), Temporary() and Timeout() methods. + net.Error // Includes the Go error interface + + // Response returns the HTTP response. You may examine this but you should not modify it. + Response() *http.Response +} + +// NewResponseError creates an error object that implements the error interface. +func NewResponseError(cause error, response *http.Response, description string) error { + if responseErrorFactory != nil { + return responseErrorFactory(cause, response, description) + } + return &responseError{ + ErrorNode: pipeline.ErrorNode{}.Initialize(cause, 3), + response: response, + description: description, + } +} + +// responseError is the internal struct that implements the public ResponseError interface. +type responseError struct { + pipeline.ErrorNode // This is embedded so that responseError "inherits" Error, Temporary, Timeout, and Cause + response *http.Response + description string +} + +// Error implements the error interface's Error method to return a string representation of the error. +func (e *responseError) Error() string { + b := &bytes.Buffer{} + fmt.Fprintf(b, "===== RESPONSE ERROR (Code=%v) =====\n", e.response.StatusCode) + fmt.Fprintf(b, "Status=%s, Description: %s\n", e.response.Status, e.description) + s := b.String() + return e.ErrorNode.Error(s) +} + +// Response implements the ResponseError interface's method to return the HTTP response. +func (e *responseError) Response() *http.Response { + return e.response +} + +// RFC7807 PROBLEM ------------------------------------------------------------------------------------ +// RFC7807Problem ... This type can be publicly embedded in another type that wants to add additional members. +/*type RFC7807Problem struct { + // Mandatory: A (relative) URI reference identifying the problem type (it MAY refer to human-readable documentation). + typeURI string // Should default to "about:blank" + // Optional: Short, human-readable summary (maybe localized). + title string + // Optional: HTTP status code generated by the origin server + status int + // Optional: Human-readable explanation for this problem occurance. + // Should help client correct the problem. Clients should NOT parse this string. + detail string + // Optional: A (relative) URI identifying this specific problem occurence (it may or may not be dereferenced). + instance string +} +// NewRFC7807Problem ... +func NewRFC7807Problem(typeURI string, status int, titleFormat string, a ...interface{}) error { + return &RFC7807Problem{ + typeURI: typeURI, + status: status, + title: fmt.Sprintf(titleFormat, a...), + } +} +// Error returns the error information as a string. +func (e *RFC7807Problem) Error() string { + return e.title +} +// TypeURI ... +func (e *RFC7807Problem) TypeURI() string { + if e.typeURI == "" { + e.typeURI = "about:blank" + } + return e.typeURI +} +// Members ... +func (e *RFC7807Problem) Members() (status int, title, detail, instance string) { + return e.status, e.title, e.detail, e.instance +}*/ diff --git a/services/appinsights/mgmt/2015-05-01/insights/validation.go b/services/appinsights/mgmt/2015-05-01/insights/validation.go new file mode 100644 index 000000000000..f6c380823754 --- /dev/null +++ b/services/appinsights/mgmt/2015-05-01/insights/validation.go @@ -0,0 +1,381 @@ +package insights + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "fmt" + "github.com/Azure/azure-pipeline-go/pipeline" + "reflect" + "regexp" + "strings" +) + +// Constraint stores constraint name, target field name +// Rule and chain validations. +type constraint struct { + // Target field name for validation. + target string + + // Constraint name e.g. minLength, MaxLength, Pattern, etc. + name string + + // Rule for constraint e.g. greater than 10, less than 5 etc. + rule interface{} + + // Chain validations for struct type + chain []constraint +} + +// Validation stores parameter-wise validation. +type validation struct { + targetValue interface{} + constraints []constraint +} + +// Constraint list +const ( + empty = "Empty" + null = "Null" + readOnly = "ReadOnly" + pattern = "Pattern" + maxLength = "MaxLength" + minLength = "MinLength" + maxItems = "MaxItems" + minItems = "MinItems" + multipleOf = "MultipleOf" + uniqueItems = "UniqueItems" + inclusiveMaximum = "InclusiveMaximum" + exclusiveMaximum = "ExclusiveMaximum" + exclusiveMinimum = "ExclusiveMinimum" + inclusiveMinimum = "InclusiveMinimum" +) + +// Validate method validates constraints on parameter +// passed in validation array. +func validate(m []validation) error { + for _, item := range m { + v := reflect.ValueOf(item.targetValue) + for _, constraint := range item.constraints { + var err error + switch v.Kind() { + case reflect.Ptr: + err = validatePtr(v, constraint) + case reflect.String: + err = validateString(v, constraint) + case reflect.Struct: + err = validateStruct(v, constraint) + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + err = validateInt(v, constraint) + case reflect.Float32, reflect.Float64: + err = validateFloat(v, constraint) + case reflect.Array, reflect.Slice, reflect.Map: + err = validateArrayMap(v, constraint) + default: + err = createError(v, constraint, fmt.Sprintf("unknown type %v", v.Kind())) + } + if err != nil { + return err + } + } + } + return nil +} + +func validateStruct(x reflect.Value, v constraint, name ...string) error { + //Get field name from target name which is in format a.b.c + s := strings.Split(v.target, ".") + f := x.FieldByName(s[len(s)-1]) + if isZero(f) { + return createError(x, v, fmt.Sprintf("field %q doesn't exist", v.target)) + } + err := validate([]validation{ + { + targetValue: getInterfaceValue(f), + constraints: []constraint{v}, + }, + }) + return err +} + +func validatePtr(x reflect.Value, v constraint) error { + if v.name == readOnly { + if !x.IsNil() { + return createError(x.Elem(), v, "readonly parameter; must send as nil or empty in request") + } + return nil + } + if x.IsNil() { + return checkNil(x, v) + } + if v.chain != nil { + return validate([]validation{ + { + targetValue: getInterfaceValue(x.Elem()), + constraints: v.chain, + }, + }) + } + return nil +} + +func validateInt(x reflect.Value, v constraint) error { + i := x.Int() + r, ok := v.rule.(int) + if !ok { + return createError(x, v, fmt.Sprintf("rule must be integer value for %v constraint; got: %v", v.name, v.rule)) + } + switch v.name { + case multipleOf: + if i%int64(r) != 0 { + return createError(x, v, fmt.Sprintf("value must be a multiple of %v", r)) + } + case exclusiveMinimum: + if i <= int64(r) { + return createError(x, v, fmt.Sprintf("value must be greater than %v", r)) + } + case exclusiveMaximum: + if i >= int64(r) { + return createError(x, v, fmt.Sprintf("value must be less than %v", r)) + } + case inclusiveMinimum: + if i < int64(r) { + return createError(x, v, fmt.Sprintf("value must be greater than or equal to %v", r)) + } + case inclusiveMaximum: + if i > int64(r) { + return createError(x, v, fmt.Sprintf("value must be less than or equal to %v", r)) + } + default: + return createError(x, v, fmt.Sprintf("constraint %v is not applicable for type integer", v.name)) + } + return nil +} + +func validateFloat(x reflect.Value, v constraint) error { + f := x.Float() + r, ok := v.rule.(float64) + if !ok { + return createError(x, v, fmt.Sprintf("rule must be float value for %v constraint; got: %v", v.name, v.rule)) + } + switch v.name { + case exclusiveMinimum: + if f <= r { + return createError(x, v, fmt.Sprintf("value must be greater than %v", r)) + } + case exclusiveMaximum: + if f >= r { + return createError(x, v, fmt.Sprintf("value must be less than %v", r)) + } + case inclusiveMinimum: + if f < r { + return createError(x, v, fmt.Sprintf("value must be greater than or equal to %v", r)) + } + case inclusiveMaximum: + if f > r { + return createError(x, v, fmt.Sprintf("value must be less than or equal to %v", r)) + } + default: + return createError(x, v, fmt.Sprintf("constraint %s is not applicable for type float", v.name)) + } + return nil +} + +func validateString(x reflect.Value, v constraint) error { + s := x.String() + switch v.name { + case empty: + if len(s) == 0 { + return checkEmpty(x, v) + } + case pattern: + reg, err := regexp.Compile(v.rule.(string)) + if err != nil { + return createError(x, v, err.Error()) + } + if !reg.MatchString(s) { + return createError(x, v, fmt.Sprintf("value doesn't match pattern %v", v.rule)) + } + case maxLength: + if _, ok := v.rule.(int); !ok { + return createError(x, v, fmt.Sprintf("rule must be integer value for %v constraint; got: %v", v.name, v.rule)) + } + if len(s) > v.rule.(int) { + return createError(x, v, fmt.Sprintf("value length must be less than %v", v.rule)) + } + case minLength: + if _, ok := v.rule.(int); !ok { + return createError(x, v, fmt.Sprintf("rule must be integer value for %v constraint; got: %v", v.name, v.rule)) + } + if len(s) < v.rule.(int) { + return createError(x, v, fmt.Sprintf("value length must be greater than %v", v.rule)) + } + case readOnly: + if len(s) > 0 { + return createError(reflect.ValueOf(s), v, "readonly parameter; must send as nil or empty in request") + } + default: + return createError(x, v, fmt.Sprintf("constraint %s is not applicable to string type", v.name)) + } + if v.chain != nil { + return validate([]validation{ + { + targetValue: getInterfaceValue(x), + constraints: v.chain, + }, + }) + } + return nil +} + +func validateArrayMap(x reflect.Value, v constraint) error { + switch v.name { + case null: + if x.IsNil() { + return checkNil(x, v) + } + case empty: + if x.IsNil() || x.Len() == 0 { + return checkEmpty(x, v) + } + case maxItems: + if _, ok := v.rule.(int); !ok { + return createError(x, v, fmt.Sprintf("rule must be integer for %v constraint; got: %v", v.name, v.rule)) + } + if x.Len() > v.rule.(int) { + return createError(x, v, fmt.Sprintf("maximum item limit is %v; got: %v", v.rule, x.Len())) + } + case minItems: + if _, ok := v.rule.(int); !ok { + return createError(x, v, fmt.Sprintf("rule must be integer for %v constraint; got: %v", v.name, v.rule)) + } + if x.Len() < v.rule.(int) { + return createError(x, v, fmt.Sprintf("minimum item limit is %v; got: %v", v.rule, x.Len())) + } + case uniqueItems: + if x.Kind() == reflect.Array || x.Kind() == reflect.Slice { + if !checkForUniqueInArray(x) { + return createError(x, v, fmt.Sprintf("all items in parameter %q must be unique; got:%v", v.target, x)) + } + } else if x.Kind() == reflect.Map { + if !checkForUniqueInMap(x) { + return createError(x, v, fmt.Sprintf("all items in parameter %q must be unique; got:%v", v.target, x)) + } + } else { + return createError(x, v, fmt.Sprintf("type must be array, slice or map for constraint %v; got: %v", v.name, x.Kind())) + } + case readOnly: + if x.Len() != 0 { + return createError(x, v, "readonly parameter; must send as nil or empty in request") + } + case pattern: + reg, err := regexp.Compile(v.rule.(string)) + if err != nil { + return createError(x, v, err.Error()) + } + keys := x.MapKeys() + for _, k := range keys { + if !reg.MatchString(k.String()) { + return createError(k, v, fmt.Sprintf("map key doesn't match pattern %v", v.rule)) + } + } + default: + return createError(x, v, fmt.Sprintf("constraint %v is not applicable to array, slice and map type", v.name)) + } + if v.chain != nil { + return validate([]validation{ + { + targetValue: getInterfaceValue(x), + constraints: v.chain, + }, + }) + } + return nil +} + +func checkNil(x reflect.Value, v constraint) error { + if _, ok := v.rule.(bool); !ok { + return createError(x, v, fmt.Sprintf("rule must be bool value for %v constraint; got: %v", v.name, v.rule)) + } + if v.rule.(bool) { + return createError(x, v, "value can not be null; required parameter") + } + return nil +} + +func checkEmpty(x reflect.Value, v constraint) error { + if _, ok := v.rule.(bool); !ok { + return createError(x, v, fmt.Sprintf("rule must be bool value for %v constraint; got: %v", v.name, v.rule)) + } + if v.rule.(bool) { + return createError(x, v, "value can not be null or empty; required parameter") + } + return nil +} + +func checkForUniqueInArray(x reflect.Value) bool { + if x == reflect.Zero(reflect.TypeOf(x)) || x.Len() == 0 { + return false + } + arrOfInterface := make([]interface{}, x.Len()) + for i := 0; i < x.Len(); i++ { + arrOfInterface[i] = x.Index(i).Interface() + } + m := make(map[interface{}]bool) + for _, val := range arrOfInterface { + if m[val] { + return false + } + m[val] = true + } + return true +} + +func checkForUniqueInMap(x reflect.Value) bool { + if x == reflect.Zero(reflect.TypeOf(x)) || x.Len() == 0 { + return false + } + mapOfInterface := make(map[interface{}]interface{}, x.Len()) + keys := x.MapKeys() + for _, k := range keys { + mapOfInterface[k.Interface()] = x.MapIndex(k).Interface() + } + m := make(map[interface{}]bool) + for _, val := range mapOfInterface { + if m[val] { + return false + } + m[val] = true + } + return true +} + +func getInterfaceValue(x reflect.Value) interface{} { + if x.Kind() == reflect.Invalid { + return nil + } + return x.Interface() +} + +func isZero(x interface{}) bool { + return x == reflect.Zero(reflect.TypeOf(x)).Interface() +} + +func createError(x reflect.Value, v constraint, message string) error { + return pipeline.NewError(nil, fmt.Sprintf("validation failed: parameter=%s constraint=%s value=%#v details: %s", + v.target, v.name, getInterfaceValue(x), message)) +} diff --git a/services/appinsights/mgmt/2015-05-01/insights/version.go b/services/appinsights/mgmt/2015-05-01/insights/version.go index a8aedaa8c186..f9405de26734 100644 --- a/services/appinsights/mgmt/2015-05-01/insights/version.go +++ b/services/appinsights/mgmt/2015-05-01/insights/version.go @@ -19,10 +19,10 @@ package insights // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v12.1.1-beta services" + return "Azure-SDK-For-Go/v12.2.1-beta arm-insights/2015-05-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v12.1.1-beta" + return "v12.2.1-beta" } diff --git a/services/appinsights/mgmt/2015-05-01/insights/web_test_locations.go b/services/appinsights/mgmt/2015-05-01/insights/web_test_locations.go new file mode 100644 index 000000000000..e0d2d5ae4769 --- /dev/null +++ b/services/appinsights/mgmt/2015-05-01/insights/web_test_locations.go @@ -0,0 +1,90 @@ +package insights + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "encoding/json" + "github.com/Azure/azure-pipeline-go/pipeline" + "io/ioutil" + "net/http" +) + +// WebTestLocationsClient is the composite Swagger for Application Insights Management Client +type WebTestLocationsClient struct { + ManagementClient +} + +// NewWebTestLocationsClient creates an instance of the WebTestLocationsClient client. +func NewWebTestLocationsClient(p pipeline.Pipeline) WebTestLocationsClient { + return WebTestLocationsClient{NewManagementClient(p)} +} + +// List gets a list of web test locations available to this Application Insights component. +// +// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights component +// resource. +func (client WebTestLocationsClient) List(ctx context.Context, resourceGroupName string, resourceName string) (*ApplicationInsightsWebTestLocationsListResult, error) { + req, err := client.listPreparer(resourceGroupName, resourceName) + if err != nil { + return nil, err + } + resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.listResponder}, req) + if err != nil { + return nil, err + } + return resp.(*ApplicationInsightsWebTestLocationsListResult), err +} + +// listPreparer prepares the List request. +func (client WebTestLocationsClient) listPreparer(resourceGroupName string, resourceName string) (pipeline.Request, error) { + u := client.url + u.Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/syntheticmonitorlocations" + req, err := pipeline.NewRequest("GET", u, nil) + if err != nil { + return req, pipeline.NewError(err, "failed to create request") + } + params := req.URL.Query() + params.Set("api-version", APIVersion) + req.URL.RawQuery = params.Encode() + return req, nil +} + +// listResponder handles the response to the List request. +func (client WebTestLocationsClient) listResponder(resp pipeline.Response) (pipeline.Response, error) { + err := validateResponse(resp, http.StatusOK) + if resp == nil { + return nil, err + } + result := &ApplicationInsightsWebTestLocationsListResult{rawResponse: resp.Response()} + if err != nil { + return result, err + } + defer resp.Response().Body.Close() + b, err := ioutil.ReadAll(resp.Response().Body) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to read response body") + } + if len(b) > 0 { + err = json.Unmarshal(b, result) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to unmarshal response body") + } + } + return result, nil +} diff --git a/services/appinsights/mgmt/2015-05-01/insights/web_tests.go b/services/appinsights/mgmt/2015-05-01/insights/web_tests.go new file mode 100644 index 000000000000..260dd208c86c --- /dev/null +++ b/services/appinsights/mgmt/2015-05-01/insights/web_tests.go @@ -0,0 +1,370 @@ +package insights + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "bytes" + "context" + "encoding/json" + "github.com/Azure/azure-pipeline-go/pipeline" + "io/ioutil" + "net/http" +) + +// WebTestsClient is the composite Swagger for Application Insights Management Client +type WebTestsClient struct { + ManagementClient +} + +// NewWebTestsClient creates an instance of the WebTestsClient client. +func NewWebTestsClient(p pipeline.Pipeline) WebTestsClient { + return WebTestsClient{NewManagementClient(p)} +} + +// CreateOrUpdate creates or updates an Application Insights web test definition. +// +// resourceGroupName is the name of the resource group. webTestName is the name of the Application Insights webtest +// resource. webTestDefinition is properties that need to be specified to create or update an Application Insights web +// test definition. +func (client WebTestsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, webTestName string, webTestDefinition WebTest) (*WebTest, error) { + if err := validate([]validation{ + {targetValue: webTestDefinition, + constraints: []constraint{{target: "webTestDefinition.WebTestProperties", name: null, rule: false, + chain: []constraint{{target: "webTestDefinition.WebTestProperties.SyntheticMonitorID", name: null, rule: true, chain: nil}, + {target: "webTestDefinition.WebTestProperties.WebTestName", name: null, rule: true, chain: nil}, + {target: "webTestDefinition.WebTestProperties.Locations", name: null, rule: true, chain: nil}, + }}}}}); err != nil { + return nil, err + } + req, err := client.createOrUpdatePreparer(resourceGroupName, webTestName, webTestDefinition) + if err != nil { + return nil, err + } + resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.createOrUpdateResponder}, req) + if err != nil { + return nil, err + } + return resp.(*WebTest), err +} + +// createOrUpdatePreparer prepares the CreateOrUpdate request. +func (client WebTestsClient) createOrUpdatePreparer(resourceGroupName string, webTestName string, webTestDefinition WebTest) (pipeline.Request, error) { + u := client.url + u.Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/webtests/{webTestName}" + req, err := pipeline.NewRequest("PUT", u, nil) + if err != nil { + return req, pipeline.NewError(err, "failed to create request") + } + params := req.URL.Query() + params.Set("api-version", APIVersion) + req.URL.RawQuery = params.Encode() + b, err := json.Marshal(webTestDefinition) + if err != nil { + return req, pipeline.NewError(err, "failed to marshal request body") + } + req.Header.Set("Content-Type", "application/json") + err = req.SetBody(bytes.NewReader(b)) + if err != nil { + return req, pipeline.NewError(err, "failed to set request body") + } + return req, nil +} + +// createOrUpdateResponder handles the response to the CreateOrUpdate request. +func (client WebTestsClient) createOrUpdateResponder(resp pipeline.Response) (pipeline.Response, error) { + err := validateResponse(resp, http.StatusOK) + if resp == nil { + return nil, err + } + result := &WebTest{rawResponse: resp.Response()} + if err != nil { + return result, err + } + defer resp.Response().Body.Close() + b, err := ioutil.ReadAll(resp.Response().Body) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to read response body") + } + if len(b) > 0 { + err = json.Unmarshal(b, result) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to unmarshal response body") + } + } + return result, nil +} + +// Delete deletes an Application Insights web test. +// +// resourceGroupName is the name of the resource group. webTestName is the name of the Application Insights webtest +// resource. +func (client WebTestsClient) Delete(ctx context.Context, resourceGroupName string, webTestName string) (*http.Response, error) { + req, err := client.deletePreparer(resourceGroupName, webTestName) + if err != nil { + return nil, err + } + resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.deleteResponder}, req) + if err != nil { + return nil, err + } + return resp.Response(), err +} + +// deletePreparer prepares the Delete request. +func (client WebTestsClient) deletePreparer(resourceGroupName string, webTestName string) (pipeline.Request, error) { + u := client.url + u.Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/webtests/{webTestName}" + req, err := pipeline.NewRequest("DELETE", u, nil) + if err != nil { + return req, pipeline.NewError(err, "failed to create request") + } + params := req.URL.Query() + params.Set("api-version", APIVersion) + req.URL.RawQuery = params.Encode() + return req, nil +} + +// deleteResponder handles the response to the Delete request. +func (client WebTestsClient) deleteResponder(resp pipeline.Response) (pipeline.Response, error) { + err := validateResponse(resp, http.StatusNoContent, http.StatusOK) + if resp == nil { + return nil, err + } + return resp, err +} + +// Get get a specific Application Insights web test definition. +// +// resourceGroupName is the name of the resource group. webTestName is the name of the Application Insights webtest +// resource. +func (client WebTestsClient) Get(ctx context.Context, resourceGroupName string, webTestName string) (*WebTest, error) { + req, err := client.getPreparer(resourceGroupName, webTestName) + if err != nil { + return nil, err + } + resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.getResponder}, req) + if err != nil { + return nil, err + } + return resp.(*WebTest), err +} + +// getPreparer prepares the Get request. +func (client WebTestsClient) getPreparer(resourceGroupName string, webTestName string) (pipeline.Request, error) { + u := client.url + u.Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/webtests/{webTestName}" + req, err := pipeline.NewRequest("GET", u, nil) + if err != nil { + return req, pipeline.NewError(err, "failed to create request") + } + params := req.URL.Query() + params.Set("api-version", APIVersion) + req.URL.RawQuery = params.Encode() + return req, nil +} + +// getResponder handles the response to the Get request. +func (client WebTestsClient) getResponder(resp pipeline.Response) (pipeline.Response, error) { + err := validateResponse(resp, http.StatusOK) + if resp == nil { + return nil, err + } + result := &WebTest{rawResponse: resp.Response()} + if err != nil { + return result, err + } + defer resp.Response().Body.Close() + b, err := ioutil.ReadAll(resp.Response().Body) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to read response body") + } + if len(b) > 0 { + err = json.Unmarshal(b, result) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to unmarshal response body") + } + } + return result, nil +} + +// List get all Application Insights web test alerts definitioned within a subscription. +func (client WebTestsClient) List(ctx context.Context) (*WebTestListResult, error) { + req, err := client.listPreparer() + if err != nil { + return nil, err + } + resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.listResponder}, req) + if err != nil { + return nil, err + } + return resp.(*WebTestListResult), err +} + +// listPreparer prepares the List request. +func (client WebTestsClient) listPreparer() (pipeline.Request, error) { + u := client.url + u.Path = "/subscriptions/{subscriptionId}/providers/microsoft.insights/webtests" + req, err := pipeline.NewRequest("GET", u, nil) + if err != nil { + return req, pipeline.NewError(err, "failed to create request") + } + params := req.URL.Query() + params.Set("api-version", APIVersion) + req.URL.RawQuery = params.Encode() + return req, nil +} + +// listResponder handles the response to the List request. +func (client WebTestsClient) listResponder(resp pipeline.Response) (pipeline.Response, error) { + err := validateResponse(resp, http.StatusOK) + if resp == nil { + return nil, err + } + result := &WebTestListResult{rawResponse: resp.Response()} + if err != nil { + return result, err + } + defer resp.Response().Body.Close() + b, err := ioutil.ReadAll(resp.Response().Body) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to read response body") + } + if len(b) > 0 { + err = json.Unmarshal(b, result) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to unmarshal response body") + } + } + return result, nil +} + +// ListByResourceGroup get all Application Insights web tests defined within a specified resource group. +// +// resourceGroupName is the name of the resource group. +func (client WebTestsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (*WebTestListResult, error) { + req, err := client.listByResourceGroupPreparer(resourceGroupName) + if err != nil { + return nil, err + } + resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.listByResourceGroupResponder}, req) + if err != nil { + return nil, err + } + return resp.(*WebTestListResult), err +} + +// listByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client WebTestsClient) listByResourceGroupPreparer(resourceGroupName string) (pipeline.Request, error) { + u := client.url + u.Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/webtests" + req, err := pipeline.NewRequest("GET", u, nil) + if err != nil { + return req, pipeline.NewError(err, "failed to create request") + } + params := req.URL.Query() + params.Set("api-version", APIVersion) + req.URL.RawQuery = params.Encode() + return req, nil +} + +// listByResourceGroupResponder handles the response to the ListByResourceGroup request. +func (client WebTestsClient) listByResourceGroupResponder(resp pipeline.Response) (pipeline.Response, error) { + err := validateResponse(resp, http.StatusOK) + if resp == nil { + return nil, err + } + result := &WebTestListResult{rawResponse: resp.Response()} + if err != nil { + return result, err + } + defer resp.Response().Body.Close() + b, err := ioutil.ReadAll(resp.Response().Body) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to read response body") + } + if len(b) > 0 { + err = json.Unmarshal(b, result) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to unmarshal response body") + } + } + return result, nil +} + +// UpdateTags creates or updates an Application Insights web test definition. +// +// resourceGroupName is the name of the resource group. webTestName is the name of the Application Insights webtest +// resource. webTestTags is updated tag information to set into the web test instance. +func (client WebTestsClient) UpdateTags(ctx context.Context, resourceGroupName string, webTestName string, webTestTags TagsResource) (*WebTest, error) { + req, err := client.updateTagsPreparer(resourceGroupName, webTestName, webTestTags) + if err != nil { + return nil, err + } + resp, err := client.Pipeline().Do(ctx, responderPolicyFactory{responder: client.updateTagsResponder}, req) + if err != nil { + return nil, err + } + return resp.(*WebTest), err +} + +// updateTagsPreparer prepares the UpdateTags request. +func (client WebTestsClient) updateTagsPreparer(resourceGroupName string, webTestName string, webTestTags TagsResource) (pipeline.Request, error) { + u := client.url + u.Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/webtests/{webTestName}" + req, err := pipeline.NewRequest("PATCH", u, nil) + if err != nil { + return req, pipeline.NewError(err, "failed to create request") + } + params := req.URL.Query() + params.Set("api-version", APIVersion) + req.URL.RawQuery = params.Encode() + b, err := json.Marshal(webTestTags) + if err != nil { + return req, pipeline.NewError(err, "failed to marshal request body") + } + req.Header.Set("Content-Type", "application/json") + err = req.SetBody(bytes.NewReader(b)) + if err != nil { + return req, pipeline.NewError(err, "failed to set request body") + } + return req, nil +} + +// updateTagsResponder handles the response to the UpdateTags request. +func (client WebTestsClient) updateTagsResponder(resp pipeline.Response) (pipeline.Response, error) { + err := validateResponse(resp, http.StatusOK) + if resp == nil { + return nil, err + } + result := &WebTest{rawResponse: resp.Response()} + if err != nil { + return result, err + } + defer resp.Response().Body.Close() + b, err := ioutil.ReadAll(resp.Response().Body) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to read response body") + } + if len(b) > 0 { + err = json.Unmarshal(b, result) + if err != nil { + return result, NewResponseError(err, resp.Response(), "failed to unmarshal response body") + } + } + return result, nil +} diff --git a/services/appinsights/mgmt/2015-05-01/insights/webtests.go b/services/appinsights/mgmt/2015-05-01/insights/webtests.go deleted file mode 100644 index 069ec99afe2f..000000000000 --- a/services/appinsights/mgmt/2015-05-01/insights/webtests.go +++ /dev/null @@ -1,506 +0,0 @@ -package insights - -// Copyright (c) Microsoft and contributors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "net/http" -) - -// WebTestsClient is the composite Swagger for Application Insights Management Client -type WebTestsClient struct { - BaseClient -} - -// NewWebTestsClient creates an instance of the WebTestsClient client. -func NewWebTestsClient(subscriptionID string) WebTestsClient { - return NewWebTestsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewWebTestsClientWithBaseURI creates an instance of the WebTestsClient client. -func NewWebTestsClientWithBaseURI(baseURI string, subscriptionID string) WebTestsClient { - return WebTestsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CreateOrUpdate creates or updates an Application Insights web test definition. -// -// resourceGroupName is the name of the resource group. webTestName is the name of the Application Insights webtest -// resource. webTestDefinition is properties that need to be specified to create or update an Application Insights web -// test definition. -func (client WebTestsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, webTestName string, webTestDefinition WebTest) (result WebTest, err error) { - if err := validation.Validate([]validation.Validation{ - {TargetValue: webTestDefinition, - Constraints: []validation.Constraint{{Target: "webTestDefinition.WebTestProperties", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "webTestDefinition.WebTestProperties.SyntheticMonitorID", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "webTestDefinition.WebTestProperties.WebTestName", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "webTestDefinition.WebTestProperties.Locations", Name: validation.Null, Rule: true, Chain: nil}, - }}}}}); err != nil { - return result, validation.NewErrorWithValidationError(err, "insights.WebTestsClient", "CreateOrUpdate") - } - - req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, webTestName, webTestDefinition) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "CreateOrUpdate", resp, "Failure sending request") - return - } - - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return -} - -// CreateOrUpdatePreparer prepares the CreateOrUpdate request. -func (client WebTestsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, webTestName string, webTestDefinition WebTest) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "webTestName": autorest.Encode("path", webTestName), - } - - const APIVersion = "2015-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsJSON(), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/webtests/{webTestName}", pathParameters), - autorest.WithJSON(webTestDefinition), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (client WebTestsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (client WebTestsClient) CreateOrUpdateResponder(resp *http.Response) (result WebTest, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Delete deletes an Application Insights web test. -// -// resourceGroupName is the name of the resource group. webTestName is the name of the Application Insights webtest -// resource. -func (client WebTestsClient) Delete(ctx context.Context, resourceGroupName string, webTestName string) (result autorest.Response, err error) { - req, err := client.DeletePreparer(ctx, resourceGroupName, webTestName) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "Delete", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "Delete", resp, "Failure sending request") - return - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "Delete", resp, "Failure responding to request") - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client WebTestsClient) DeletePreparer(ctx context.Context, resourceGroupName string, webTestName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "webTestName": autorest.Encode("path", webTestName), - } - - const APIVersion = "2015-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/webtests/{webTestName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client WebTestsClient) DeleteSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client WebTestsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// Get get a specific Application Insights web test definition. -// -// resourceGroupName is the name of the resource group. webTestName is the name of the Application Insights webtest -// resource. -func (client WebTestsClient) Get(ctx context.Context, resourceGroupName string, webTestName string) (result WebTest, err error) { - req, err := client.GetPreparer(ctx, resourceGroupName, webTestName) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "Get", resp, "Failure responding to request") - } - - return -} - -// GetPreparer prepares the Get request. -func (client WebTestsClient) GetPreparer(ctx context.Context, resourceGroupName string, webTestName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "webTestName": autorest.Encode("path", webTestName), - } - - const APIVersion = "2015-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/webtests/{webTestName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client WebTestsClient) GetSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client WebTestsClient) GetResponder(resp *http.Response) (result WebTest, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// List get all Application Insights web test alerts definitioned within a subscription. -func (client WebTestsClient) List(ctx context.Context) (result WebTestListResultPage, err error) { - result.fn = client.listNextResults - req, err := client.ListPreparer(ctx) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.wtlr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "List", resp, "Failure sending request") - return - } - - result.wtlr, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "List", resp, "Failure responding to request") - } - - return -} - -// ListPreparer prepares the List request. -func (client WebTestsClient) ListPreparer(ctx context.Context) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2015-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/microsoft.insights/webtests", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client WebTestsClient) ListSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client WebTestsClient) ListResponder(resp *http.Response) (result WebTestListResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listNextResults retrieves the next set of results, if any. -func (client WebTestsClient) listNextResults(lastResults WebTestListResult) (result WebTestListResult, err error) { - req, err := lastResults.webTestListResultPreparer() - if err != nil { - return result, autorest.NewErrorWithError(err, "insights.WebTestsClient", "listNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "insights.WebTestsClient", "listNextResults", resp, "Failure sending next results request") - } - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "listNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListComplete enumerates all values, automatically crossing page boundaries as required. -func (client WebTestsClient) ListComplete(ctx context.Context) (result WebTestListResultIterator, err error) { - result.page, err = client.List(ctx) - return -} - -// ListByResourceGroup get all Application Insights web tests defined within a specified resource group. -// -// resourceGroupName is the name of the resource group. -func (client WebTestsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result WebTestListResultPage, err error) { - result.fn = client.listByResourceGroupNextResults - req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - resp, err := client.ListByResourceGroupSender(req) - if err != nil { - result.wtlr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "ListByResourceGroup", resp, "Failure sending request") - return - } - - result.wtlr, err = client.ListByResourceGroupResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "ListByResourceGroup", resp, "Failure responding to request") - } - - return -} - -// ListByResourceGroupPreparer prepares the ListByResourceGroup request. -func (client WebTestsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2015-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/webtests", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the -// http.Response Body if it receives an error. -func (client WebTestsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always -// closes the http.Response Body. -func (client WebTestsClient) ListByResourceGroupResponder(resp *http.Response) (result WebTestListResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listByResourceGroupNextResults retrieves the next set of results, if any. -func (client WebTestsClient) listByResourceGroupNextResults(lastResults WebTestListResult) (result WebTestListResult, err error) { - req, err := lastResults.webTestListResultPreparer() - if err != nil { - return result, autorest.NewErrorWithError(err, "insights.WebTestsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListByResourceGroupSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "insights.WebTestsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") - } - result, err = client.ListByResourceGroupResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. -func (client WebTestsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result WebTestListResultIterator, err error) { - result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) - return -} - -// UpdateTags creates or updates an Application Insights web test definition. -// -// resourceGroupName is the name of the resource group. webTestName is the name of the Application Insights webtest -// resource. webTestTags is updated tag information to set into the web test instance. -func (client WebTestsClient) UpdateTags(ctx context.Context, resourceGroupName string, webTestName string, webTestTags TagsResource) (result WebTest, err error) { - req, err := client.UpdateTagsPreparer(ctx, resourceGroupName, webTestName, webTestTags) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "UpdateTags", nil, "Failure preparing request") - return - } - - resp, err := client.UpdateTagsSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "UpdateTags", resp, "Failure sending request") - return - } - - result, err = client.UpdateTagsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "UpdateTags", resp, "Failure responding to request") - } - - return -} - -// UpdateTagsPreparer prepares the UpdateTags request. -func (client WebTestsClient) UpdateTagsPreparer(ctx context.Context, resourceGroupName string, webTestName string, webTestTags TagsResource) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "webTestName": autorest.Encode("path", webTestName), - } - - const APIVersion = "2015-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsJSON(), - autorest.AsPatch(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/webtests/{webTestName}", pathParameters), - autorest.WithJSON(webTestTags), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// UpdateTagsSender sends the UpdateTags request. The method will close the -// http.Response Body if it receives an error. -func (client WebTestsClient) UpdateTagsSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// UpdateTagsResponder handles the response to the UpdateTags request. The method always -// closes the http.Response Body. -func (client WebTestsClient) UpdateTagsResponder(resp *http.Response) (result WebTest, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -}