diff --git a/services/appinsights/mgmt/2015-05-01/insights/annotations.go b/services/appinsights/mgmt/2015-05-01/insights/annotations.go new file mode 100644 index 000000000000..d7dc46edfa81 --- /dev/null +++ b/services/appinsights/mgmt/2015-05-01/insights/annotations.go @@ -0,0 +1,318 @@ +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" +) + +// AnnotationsClient is the composite Swagger for Application Insights Management Client +type AnnotationsClient struct { + BaseClient +} + +// NewAnnotationsClient creates an instance of the AnnotationsClient client. +func NewAnnotationsClient(subscriptionID string, purgeID string) AnnotationsClient { + return NewAnnotationsClientWithBaseURI(DefaultBaseURI, subscriptionID, purgeID) +} + +// NewAnnotationsClientWithBaseURI creates an instance of the AnnotationsClient client. +func NewAnnotationsClientWithBaseURI(baseURI string, subscriptionID string, purgeID string) AnnotationsClient { + return AnnotationsClient{NewWithBaseURI(baseURI, subscriptionID, purgeID)} +} + +// Create create an Annotation of an Application Insights component. +// +// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights +// component resource. annotationProperties is properties that need to be specified to create an annotation of a +// Application Insights component. +func (client AnnotationsClient) Create(ctx context.Context, resourceGroupName string, resourceName string, annotationProperties Annotation) (result ListAnnotation, err error) { + req, err := client.CreatePreparer(ctx, resourceGroupName, resourceName, annotationProperties) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AnnotationsClient", "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.AnnotationsClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AnnotationsClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client AnnotationsClient) CreatePreparer(ctx context.Context, resourceGroupName string, resourceName string, annotationProperties Annotation) (*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}/Annotations", pathParameters), + autorest.WithJSON(annotationProperties), + 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 AnnotationsClient) 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 AnnotationsClient) CreateResponder(resp *http.Response) (result ListAnnotation, 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 an Annotation of an Application Insights component. +// +// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights +// component resource. annotationID is the unique annotation ID. This is unique within a Application Insights +// component. +func (client AnnotationsClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, annotationID string) (result SetObject, err error) { + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName, annotationID) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AnnotationsClient", "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.AnnotationsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AnnotationsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client AnnotationsClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string, annotationID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "annotationId": autorest.Encode("path", annotationID), + "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}/Annotations/{annotationId}", 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 AnnotationsClient) 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 AnnotationsClient) DeleteResponder(resp *http.Response) (result SetObject, 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 +} + +// Get get the annotation for given id. +// +// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights +// component resource. annotationID is the unique annotation ID. This is unique within a Application Insights +// component. +func (client AnnotationsClient) Get(ctx context.Context, resourceGroupName string, resourceName string, annotationID string) (result ListAnnotation, err error) { + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName, annotationID) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AnnotationsClient", "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.AnnotationsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AnnotationsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AnnotationsClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string, annotationID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "annotationId": autorest.Encode("path", annotationID), + "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}/Annotations/{annotationId}", 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 AnnotationsClient) 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 AnnotationsClient) GetResponder(resp *http.Response) (result ListAnnotation, 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 +} + +// List gets the list of annotations for a component for given time range +// +// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights +// component resource. start is the start time to query from for annotations, cannot be older than 90 days from +// current date. end is the end time to query for annotations. +func (client AnnotationsClient) List(ctx context.Context, resourceGroupName string, resourceName string, start string, end string) (result ListAnnotation, err error) { + req, err := client.ListPreparer(ctx, resourceGroupName, resourceName, start, end) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AnnotationsClient", "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.AnnotationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AnnotationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client AnnotationsClient) ListPreparer(ctx context.Context, resourceGroupName string, resourceName string, start string, end 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, + "end": autorest.Encode("query", end), + "start": autorest.Encode("query", start), + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/Annotations", 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 AnnotationsClient) 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 AnnotationsClient) ListResponder(resp *http.Response) (result ListAnnotation, 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 +} diff --git a/services/appinsights/mgmt/2015-05-01/insights/apikeys.go b/services/appinsights/mgmt/2015-05-01/insights/apikeys.go index 5fc5b38a2ec8..640cd9d372c3 100644 --- a/services/appinsights/mgmt/2015-05-01/insights/apikeys.go +++ b/services/appinsights/mgmt/2015-05-01/insights/apikeys.go @@ -30,13 +30,13 @@ type APIKeysClient struct { } // NewAPIKeysClient creates an instance of the APIKeysClient client. -func NewAPIKeysClient(subscriptionID string) APIKeysClient { - return NewAPIKeysClientWithBaseURI(DefaultBaseURI, subscriptionID) +func NewAPIKeysClient(subscriptionID string, purgeID string) APIKeysClient { + return NewAPIKeysClientWithBaseURI(DefaultBaseURI, subscriptionID, purgeID) } // NewAPIKeysClientWithBaseURI creates an instance of the APIKeysClient client. -func NewAPIKeysClientWithBaseURI(baseURI string, subscriptionID string) APIKeysClient { - return APIKeysClient{NewWithBaseURI(baseURI, subscriptionID)} +func NewAPIKeysClientWithBaseURI(baseURI string, subscriptionID string, purgeID string) APIKeysClient { + return APIKeysClient{NewWithBaseURI(baseURI, subscriptionID, purgeID)} } // Create create an API Key of an Application Insights component. diff --git a/services/appinsights/mgmt/2015-05-01/insights/client.go b/services/appinsights/mgmt/2015-05-01/insights/client.go index 8508d449fead..19398ab010e7 100644 --- a/services/appinsights/mgmt/2015-05-01/insights/client.go +++ b/services/appinsights/mgmt/2015-05-01/insights/client.go @@ -34,18 +34,20 @@ type BaseClient struct { autorest.Client BaseURI string SubscriptionID string + PurgeID string } // New creates an instance of the BaseClient client. -func New(subscriptionID string) BaseClient { - return NewWithBaseURI(DefaultBaseURI, subscriptionID) +func New(subscriptionID string, purgeID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID, purgeID) } // NewWithBaseURI creates an instance of the BaseClient client. -func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { +func NewWithBaseURI(baseURI string, subscriptionID string, purgeID string) BaseClient { return BaseClient{ Client: autorest.NewClientWithUserAgent(UserAgent()), BaseURI: baseURI, SubscriptionID: subscriptionID, + PurgeID: purgeID, } } diff --git a/services/appinsights/mgmt/2015-05-01/insights/componentavailablefeatures.go b/services/appinsights/mgmt/2015-05-01/insights/componentavailablefeatures.go index a85be906fff8..6fbfe2239fa1 100644 --- a/services/appinsights/mgmt/2015-05-01/insights/componentavailablefeatures.go +++ b/services/appinsights/mgmt/2015-05-01/insights/componentavailablefeatures.go @@ -30,13 +30,13 @@ type ComponentAvailableFeaturesClient struct { } // NewComponentAvailableFeaturesClient creates an instance of the ComponentAvailableFeaturesClient client. -func NewComponentAvailableFeaturesClient(subscriptionID string) ComponentAvailableFeaturesClient { - return NewComponentAvailableFeaturesClientWithBaseURI(DefaultBaseURI, subscriptionID) +func NewComponentAvailableFeaturesClient(subscriptionID string, purgeID string) ComponentAvailableFeaturesClient { + return NewComponentAvailableFeaturesClientWithBaseURI(DefaultBaseURI, subscriptionID, purgeID) } // NewComponentAvailableFeaturesClientWithBaseURI creates an instance of the ComponentAvailableFeaturesClient client. -func NewComponentAvailableFeaturesClientWithBaseURI(baseURI string, subscriptionID string) ComponentAvailableFeaturesClient { - return ComponentAvailableFeaturesClient{NewWithBaseURI(baseURI, subscriptionID)} +func NewComponentAvailableFeaturesClientWithBaseURI(baseURI string, subscriptionID string, purgeID string) ComponentAvailableFeaturesClient { + return ComponentAvailableFeaturesClient{NewWithBaseURI(baseURI, subscriptionID, purgeID)} } // Get returns all available features of the application insights component. diff --git a/services/appinsights/mgmt/2015-05-01/insights/componentcurrentbillingfeatures.go b/services/appinsights/mgmt/2015-05-01/insights/componentcurrentbillingfeatures.go index f0231d4aca04..3c29e249d52c 100644 --- a/services/appinsights/mgmt/2015-05-01/insights/componentcurrentbillingfeatures.go +++ b/services/appinsights/mgmt/2015-05-01/insights/componentcurrentbillingfeatures.go @@ -30,14 +30,14 @@ type ComponentCurrentBillingFeaturesClient struct { } // NewComponentCurrentBillingFeaturesClient creates an instance of the ComponentCurrentBillingFeaturesClient client. -func NewComponentCurrentBillingFeaturesClient(subscriptionID string) ComponentCurrentBillingFeaturesClient { - return NewComponentCurrentBillingFeaturesClientWithBaseURI(DefaultBaseURI, subscriptionID) +func NewComponentCurrentBillingFeaturesClient(subscriptionID string, purgeID string) ComponentCurrentBillingFeaturesClient { + return NewComponentCurrentBillingFeaturesClientWithBaseURI(DefaultBaseURI, subscriptionID, purgeID) } // NewComponentCurrentBillingFeaturesClientWithBaseURI creates an instance of the ComponentCurrentBillingFeaturesClient // client. -func NewComponentCurrentBillingFeaturesClientWithBaseURI(baseURI string, subscriptionID string) ComponentCurrentBillingFeaturesClient { - return ComponentCurrentBillingFeaturesClient{NewWithBaseURI(baseURI, subscriptionID)} +func NewComponentCurrentBillingFeaturesClientWithBaseURI(baseURI string, subscriptionID string, purgeID string) ComponentCurrentBillingFeaturesClient { + return ComponentCurrentBillingFeaturesClient{NewWithBaseURI(baseURI, subscriptionID, purgeID)} } // Get returns current billing features for an Application Insights component. diff --git a/services/appinsights/mgmt/2015-05-01/insights/componentfeaturecapabilities.go b/services/appinsights/mgmt/2015-05-01/insights/componentfeaturecapabilities.go index bbf01e178559..1b05ad3d7261 100644 --- a/services/appinsights/mgmt/2015-05-01/insights/componentfeaturecapabilities.go +++ b/services/appinsights/mgmt/2015-05-01/insights/componentfeaturecapabilities.go @@ -30,14 +30,14 @@ type ComponentFeatureCapabilitiesClient struct { } // NewComponentFeatureCapabilitiesClient creates an instance of the ComponentFeatureCapabilitiesClient client. -func NewComponentFeatureCapabilitiesClient(subscriptionID string) ComponentFeatureCapabilitiesClient { - return NewComponentFeatureCapabilitiesClientWithBaseURI(DefaultBaseURI, subscriptionID) +func NewComponentFeatureCapabilitiesClient(subscriptionID string, purgeID string) ComponentFeatureCapabilitiesClient { + return NewComponentFeatureCapabilitiesClientWithBaseURI(DefaultBaseURI, subscriptionID, purgeID) } // NewComponentFeatureCapabilitiesClientWithBaseURI creates an instance of the ComponentFeatureCapabilitiesClient // client. -func NewComponentFeatureCapabilitiesClientWithBaseURI(baseURI string, subscriptionID string) ComponentFeatureCapabilitiesClient { - return ComponentFeatureCapabilitiesClient{NewWithBaseURI(baseURI, subscriptionID)} +func NewComponentFeatureCapabilitiesClientWithBaseURI(baseURI string, subscriptionID string, purgeID string) ComponentFeatureCapabilitiesClient { + return ComponentFeatureCapabilitiesClient{NewWithBaseURI(baseURI, subscriptionID, purgeID)} } // Get returns feature capabilites of the application insights component. diff --git a/services/appinsights/mgmt/2015-05-01/insights/componentquotastatus.go b/services/appinsights/mgmt/2015-05-01/insights/componentquotastatus.go index c3db2737040e..87e7285bb4cc 100644 --- a/services/appinsights/mgmt/2015-05-01/insights/componentquotastatus.go +++ b/services/appinsights/mgmt/2015-05-01/insights/componentquotastatus.go @@ -30,13 +30,13 @@ type ComponentQuotaStatusClient struct { } // NewComponentQuotaStatusClient creates an instance of the ComponentQuotaStatusClient client. -func NewComponentQuotaStatusClient(subscriptionID string) ComponentQuotaStatusClient { - return NewComponentQuotaStatusClientWithBaseURI(DefaultBaseURI, subscriptionID) +func NewComponentQuotaStatusClient(subscriptionID string, purgeID string) ComponentQuotaStatusClient { + return NewComponentQuotaStatusClientWithBaseURI(DefaultBaseURI, subscriptionID, purgeID) } // NewComponentQuotaStatusClientWithBaseURI creates an instance of the ComponentQuotaStatusClient client. -func NewComponentQuotaStatusClientWithBaseURI(baseURI string, subscriptionID string) ComponentQuotaStatusClient { - return ComponentQuotaStatusClient{NewWithBaseURI(baseURI, subscriptionID)} +func NewComponentQuotaStatusClientWithBaseURI(baseURI string, subscriptionID string, purgeID string) ComponentQuotaStatusClient { + return ComponentQuotaStatusClient{NewWithBaseURI(baseURI, subscriptionID, purgeID)} } // Get returns daily data volume cap (quota) status for an Application Insights component. diff --git a/services/appinsights/mgmt/2015-05-01/insights/components.go b/services/appinsights/mgmt/2015-05-01/insights/components.go index 5d57cd06bd86..7b833941f892 100644 --- a/services/appinsights/mgmt/2015-05-01/insights/components.go +++ b/services/appinsights/mgmt/2015-05-01/insights/components.go @@ -31,13 +31,13 @@ type ComponentsClient struct { } // NewComponentsClient creates an instance of the ComponentsClient client. -func NewComponentsClient(subscriptionID string) ComponentsClient { - return NewComponentsClientWithBaseURI(DefaultBaseURI, subscriptionID) +func NewComponentsClient(subscriptionID string, purgeID string) ComponentsClient { + return NewComponentsClientWithBaseURI(DefaultBaseURI, subscriptionID, purgeID) } // NewComponentsClientWithBaseURI creates an instance of the ComponentsClient client. -func NewComponentsClientWithBaseURI(baseURI string, subscriptionID string) ComponentsClient { - return ComponentsClient{NewWithBaseURI(baseURI, subscriptionID)} +func NewComponentsClientWithBaseURI(baseURI string, subscriptionID string, purgeID string) ComponentsClient { + return ComponentsClient{NewWithBaseURI(baseURI, subscriptionID, purgeID)} } // CreateOrUpdate creates (or updates) an Application Insights component. Note: You cannot specify a different value @@ -250,6 +250,75 @@ func (client ComponentsClient) GetResponder(resp *http.Response) (result Applica return } +// GetPurgeStatus gets the status of a previously submitted purge using the id returned from the original purge +// request. +// +// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights +// component resource. +func (client ComponentsClient) GetPurgeStatus(ctx context.Context, resourceGroupName string, resourceName string) (result ComponentPurgeStatusResponse, err error) { + req, err := client.GetPurgeStatusPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "GetPurgeStatus", nil, "Failure preparing request") + return + } + + resp, err := client.GetPurgeStatusSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "GetPurgeStatus", resp, "Failure sending request") + return + } + + result, err = client.GetPurgeStatusResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "GetPurgeStatus", resp, "Failure responding to request") + } + + return +} + +// GetPurgeStatusPreparer prepares the GetPurgeStatus request. +func (client ComponentsClient) GetPurgeStatusPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "purgeId": autorest.Encode("path", client.PurgeID), + "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}/operations/{purgeId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetPurgeStatusSender sends the GetPurgeStatus request. The method will close the +// http.Response Body if it receives an error. +func (client ComponentsClient) GetPurgeStatusSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetPurgeStatusResponder handles the response to the GetPurgeStatus request. The method always +// closes the http.Response Body. +func (client ComponentsClient) GetPurgeStatusResponder(resp *http.Response) (result ComponentPurgeStatusResponse, 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 all Application Insights components within a subscription. func (client ComponentsClient) List(ctx context.Context) (result ApplicationInsightsComponentListResultPage, err error) { result.fn = client.listNextResults @@ -433,6 +502,83 @@ func (client ComponentsClient) ListByResourceGroupComplete(ctx context.Context, return } +// Purge purges data in an Application Insights component by a set of user-defined filters. +// +// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights +// component resource. body is describes the body of a request to purge data in a single table of an Application +// Insights component +func (client ComponentsClient) Purge(ctx context.Context, resourceGroupName string, resourceName string, body ComponentPurgeBody) (result ComponentPurgeResponse, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: body, + Constraints: []validation.Constraint{{Target: "body.Table", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "body.Filters", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ComponentsClient", "Purge", err.Error()) + } + + req, err := client.PurgePreparer(ctx, resourceGroupName, resourceName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "Purge", nil, "Failure preparing request") + return + } + + resp, err := client.PurgeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "Purge", resp, "Failure sending request") + return + } + + result, err = client.PurgeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "Purge", resp, "Failure responding to request") + } + + return +} + +// PurgePreparer prepares the Purge request. +func (client ComponentsClient) PurgePreparer(ctx context.Context, resourceGroupName string, resourceName string, body ComponentPurgeBody) (*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}/purge", pathParameters), + autorest.WithJSON(body), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// PurgeSender sends the Purge request. The method will close the +// http.Response Body if it receives an error. +func (client ComponentsClient) PurgeSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// PurgeResponder handles the response to the Purge request. The method always +// closes the http.Response Body. +func (client ComponentsClient) PurgeResponder(resp *http.Response) (result ComponentPurgeResponse, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + // 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 diff --git a/services/appinsights/mgmt/2015-05-01/insights/exportconfigurations.go b/services/appinsights/mgmt/2015-05-01/insights/exportconfigurations.go index 96b323e578c9..6dd4bd23f252 100644 --- a/services/appinsights/mgmt/2015-05-01/insights/exportconfigurations.go +++ b/services/appinsights/mgmt/2015-05-01/insights/exportconfigurations.go @@ -30,13 +30,13 @@ type ExportConfigurationsClient struct { } // NewExportConfigurationsClient creates an instance of the ExportConfigurationsClient client. -func NewExportConfigurationsClient(subscriptionID string) ExportConfigurationsClient { - return NewExportConfigurationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +func NewExportConfigurationsClient(subscriptionID string, purgeID string) ExportConfigurationsClient { + return NewExportConfigurationsClientWithBaseURI(DefaultBaseURI, subscriptionID, purgeID) } // NewExportConfigurationsClientWithBaseURI creates an instance of the ExportConfigurationsClient client. -func NewExportConfigurationsClientWithBaseURI(baseURI string, subscriptionID string) ExportConfigurationsClient { - return ExportConfigurationsClient{NewWithBaseURI(baseURI, subscriptionID)} +func NewExportConfigurationsClientWithBaseURI(baseURI string, subscriptionID string, purgeID string) ExportConfigurationsClient { + return ExportConfigurationsClient{NewWithBaseURI(baseURI, subscriptionID, purgeID)} } // Create create a Continuous Export configuration of an Application Insights component. diff --git a/services/appinsights/mgmt/2015-05-01/insights/models.go b/services/appinsights/mgmt/2015-05-01/insights/models.go index 9647d2e11607..f1940b579603 100644 --- a/services/appinsights/mgmt/2015-05-01/insights/models.go +++ b/services/appinsights/mgmt/2015-05-01/insights/models.go @@ -43,6 +43,16 @@ const ( Bluefield FlowType = "Bluefield" ) +// PurgeState enumerates the values for purge state. +type PurgeState string + +const ( + // Completed ... + Completed PurgeState = "Completed" + // Pending ... + Pending PurgeState = "Pending" +) + // RequestSource enumerates the values for request source. type RequestSource string @@ -61,6 +71,31 @@ const ( Ping WebTestKind = "ping" ) +// Annotation annotation associated with an application insights resource. +type Annotation struct { + // AnnotationName - Name of annotation + AnnotationName *string `json:"AnnotationName,omitempty"` + // Category - Category of annotation, free form + Category *string `json:"Category,omitempty"` + // EventTime - Time when event occurred + EventTime *date.Time `json:"EventTime,omitempty"` + // ID - Unique Id for annotation + ID *string `json:"Id,omitempty"` + // Properties - Serialized JSON object for detailed properties + Properties *string `json:"Properties,omitempty"` + // RelatedAnnotation - Related parent annotation if any + RelatedAnnotation *string `json:"RelatedAnnotation,omitempty"` +} + +// AnnotationError error associated with trying to create annotation with Id that already exist +type AnnotationError struct { + // Code - Error detail code and explanation + Code *string `json:"code,omitempty"` + // Message - Error message + Message *string `json:"message,omitempty"` + Innererror *InnerError `json:"innererror,omitempty"` +} + // APIKeyRequest an Application Insights component API Key createion request definition. type APIKeyRequest struct { // Name - The name of the API Key. @@ -574,6 +609,36 @@ type ApplicationInsightsComponentQuotaStatus struct { ExpirationTime *string `json:"ExpirationTime,omitempty"` } +// ComponentPurgeBody describes the body of a purge request for an App Insights component +type ComponentPurgeBody struct { + // Table - Table from which to purge data. + Table *string `json:"table,omitempty"` + // Filters - The set of columns and filters (queries) to run over them to purge the resulting data. + Filters *[]ComponentPurgeBodyFilters `json:"filters,omitempty"` +} + +// ComponentPurgeBodyFilters user-defined filters to return data which will be purged from the table. +type ComponentPurgeBodyFilters struct { + // Column - The column of the table over which the given query should run + Column *string `json:"column,omitempty"` + // Filter - A query to to run over the provided table and column to purge the corresponding data. + Filter *string `json:"filter,omitempty"` +} + +// ComponentPurgeResponse response containing operationId for a specific purge action. +type ComponentPurgeResponse struct { + autorest.Response `json:"-"` + // OperationID - Id to use when querying for status for a particular purge operation. + OperationID *string `json:"operationId,omitempty"` +} + +// ComponentPurgeStatusResponse response containing status for a specific purge operation. +type ComponentPurgeStatusResponse struct { + autorest.Response `json:"-"` + // Status - Status of the operation represented by the requested Id. Possible values include: 'Pending', 'Completed' + Status PurgeState `json:"status,omitempty"` +} + // 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 { @@ -583,6 +648,20 @@ type ErrorResponse struct { Message *string `json:"message,omitempty"` } +// InnerError inner error +type InnerError struct { + // Diagnosticcontext - Provides correlation for request + Diagnosticcontext *string `json:"diagnosticcontext,omitempty"` + // Time - Request time + Time *date.Time `json:"time,omitempty"` +} + +// ListAnnotation ... +type ListAnnotation struct { + autorest.Response `json:"-"` + Value *[]Annotation `json:"value,omitempty"` +} + // ListApplicationInsightsComponentExportConfiguration ... type ListApplicationInsightsComponentExportConfiguration struct { autorest.Response `json:"-"` @@ -595,6 +674,12 @@ type ListApplicationInsightsComponentProactiveDetectionConfiguration struct { Value *[]ApplicationInsightsComponentProactiveDetectionConfiguration `json:"value,omitempty"` } +// ListWorkItemConfiguration ... +type ListWorkItemConfiguration struct { + autorest.Response `json:"-"` + Value *[]WorkItemConfiguration `json:"value,omitempty"` +} + // Operation CDN REST API operation type Operation struct { // Name - Operation name: {provider}/{resource}/{operation} @@ -751,6 +836,12 @@ func (r Resource) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } +// SetObject ... +type SetObject struct { + autorest.Response `json:"-"` + Value interface{} `json:"value,omitempty"` +} + // TagsResource a container holding only the Tags for a resource, allowing the user to update the tags on a WebTest // instance. type TagsResource struct { @@ -1029,3 +1120,39 @@ type WebTestPropertiesConfiguration struct { // WebTest - The XML specification of a WebTest to run against an application. WebTest *string `json:"WebTest,omitempty"` } + +// WorkItemConfiguration work item configuration associated with an application insights resource. +type WorkItemConfiguration struct { + autorest.Response `json:"-"` + // ConnectorID - Connector identifier where work item is created + ConnectorID *string `json:"ConnectorId,omitempty"` + // ConfigDisplayName - Configuration friendly name + ConfigDisplayName *string `json:"ConfigDisplayName,omitempty"` + // IsDefault - Boolean value indicating whether configuration is default + IsDefault *bool `json:"IsDefault,omitempty"` + // ID - Unique Id for work item + ID *string `json:"Id,omitempty"` + // ConfigProperties - Serialized JSON object for detailed properties + ConfigProperties *string `json:"ConfigProperties,omitempty"` +} + +// WorkItemConfigurationError error associated with trying to get work item configuration or configurations +type WorkItemConfigurationError struct { + // Code - Error detail code and explanation + Code *string `json:"code,omitempty"` + // Message - Error message + Message *string `json:"message,omitempty"` + Innererror *InnerError `json:"innererror,omitempty"` +} + +// WorkItemCreateConfiguration work item configuration creation payload +type WorkItemCreateConfiguration struct { + // ConnectorID - Unique connector id + ConnectorID *string `json:"ConnectorId,omitempty"` + // ConnectorDataConfiguration - Serialized JSON object for detaile d properties + ConnectorDataConfiguration *string `json:"ConnectorDataConfiguration,omitempty"` + // ValidateOnly - Boolean indicating validate only + ValidateOnly *bool `json:"ValidateOnly,omitempty"` + // WorkItemProperties - Custom work item properties + WorkItemProperties *string `json:"WorkItemProperties,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..a8ee742853e7 100644 --- a/services/appinsights/mgmt/2015-05-01/insights/operations.go +++ b/services/appinsights/mgmt/2015-05-01/insights/operations.go @@ -30,13 +30,13 @@ type OperationsClient struct { } // NewOperationsClient creates an instance of the OperationsClient client. -func NewOperationsClient(subscriptionID string) OperationsClient { - return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +func NewOperationsClient(subscriptionID string, purgeID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID, purgeID) } // NewOperationsClientWithBaseURI creates an instance of the OperationsClient client. -func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { - return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string, purgeID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID, purgeID)} } // List lists all of the available insights REST API operations. diff --git a/services/appinsights/mgmt/2015-05-01/insights/proactivedetectionconfigurations.go b/services/appinsights/mgmt/2015-05-01/insights/proactivedetectionconfigurations.go index 0b4a630df137..f9b9607d7acf 100644 --- a/services/appinsights/mgmt/2015-05-01/insights/proactivedetectionconfigurations.go +++ b/services/appinsights/mgmt/2015-05-01/insights/proactivedetectionconfigurations.go @@ -30,14 +30,14 @@ type ProactiveDetectionConfigurationsClient struct { } // NewProactiveDetectionConfigurationsClient creates an instance of the ProactiveDetectionConfigurationsClient client. -func NewProactiveDetectionConfigurationsClient(subscriptionID string) ProactiveDetectionConfigurationsClient { - return NewProactiveDetectionConfigurationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +func NewProactiveDetectionConfigurationsClient(subscriptionID string, purgeID string) ProactiveDetectionConfigurationsClient { + return NewProactiveDetectionConfigurationsClientWithBaseURI(DefaultBaseURI, subscriptionID, purgeID) } // NewProactiveDetectionConfigurationsClientWithBaseURI creates an instance of the // ProactiveDetectionConfigurationsClient client. -func NewProactiveDetectionConfigurationsClientWithBaseURI(baseURI string, subscriptionID string) ProactiveDetectionConfigurationsClient { - return ProactiveDetectionConfigurationsClient{NewWithBaseURI(baseURI, subscriptionID)} +func NewProactiveDetectionConfigurationsClientWithBaseURI(baseURI string, subscriptionID string, purgeID string) ProactiveDetectionConfigurationsClient { + return ProactiveDetectionConfigurationsClient{NewWithBaseURI(baseURI, subscriptionID, purgeID)} } // Get get the ProactiveDetection configuration for this configuration id. diff --git a/services/appinsights/mgmt/2015-05-01/insights/version.go b/services/appinsights/mgmt/2015-05-01/insights/version.go index 313c6d6bdd74..fdeb26fe1aec 100644 --- a/services/appinsights/mgmt/2015-05-01/insights/version.go +++ b/services/appinsights/mgmt/2015-05-01/insights/version.go @@ -1,7 +1,5 @@ package insights -import "github.com/Azure/azure-sdk-for-go/version" - // Copyright (c) Microsoft and contributors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,10 +19,10 @@ import "github.com/Azure/azure-sdk-for-go/version" // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/" + version.Number + " insights/2015-05-01" + return "Azure-SDK-For-Go/latest services" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return version.Number + return "latest" } diff --git a/services/appinsights/mgmt/2015-05-01/insights/webtests.go b/services/appinsights/mgmt/2015-05-01/insights/webtests.go index 447a7ede0d0a..f5e0d08dafdd 100644 --- a/services/appinsights/mgmt/2015-05-01/insights/webtests.go +++ b/services/appinsights/mgmt/2015-05-01/insights/webtests.go @@ -31,13 +31,13 @@ type WebTestsClient struct { } // NewWebTestsClient creates an instance of the WebTestsClient client. -func NewWebTestsClient(subscriptionID string) WebTestsClient { - return NewWebTestsClientWithBaseURI(DefaultBaseURI, subscriptionID) +func NewWebTestsClient(subscriptionID string, purgeID string) WebTestsClient { + return NewWebTestsClientWithBaseURI(DefaultBaseURI, subscriptionID, purgeID) } // NewWebTestsClientWithBaseURI creates an instance of the WebTestsClient client. -func NewWebTestsClientWithBaseURI(baseURI string, subscriptionID string) WebTestsClient { - return WebTestsClient{NewWithBaseURI(baseURI, subscriptionID)} +func NewWebTestsClientWithBaseURI(baseURI string, subscriptionID string, purgeID string) WebTestsClient { + return WebTestsClient{NewWithBaseURI(baseURI, subscriptionID, purgeID)} } // CreateOrUpdate creates or updates an Application Insights web test definition. diff --git a/services/appinsights/mgmt/2015-05-01/insights/workitemconfigurations.go b/services/appinsights/mgmt/2015-05-01/insights/workitemconfigurations.go new file mode 100644 index 000000000000..d5912c75d0d9 --- /dev/null +++ b/services/appinsights/mgmt/2015-05-01/insights/workitemconfigurations.go @@ -0,0 +1,313 @@ +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" +) + +// WorkItemConfigurationsClient is the composite Swagger for Application Insights Management Client +type WorkItemConfigurationsClient struct { + BaseClient +} + +// NewWorkItemConfigurationsClient creates an instance of the WorkItemConfigurationsClient client. +func NewWorkItemConfigurationsClient(subscriptionID string, purgeID string) WorkItemConfigurationsClient { + return NewWorkItemConfigurationsClientWithBaseURI(DefaultBaseURI, subscriptionID, purgeID) +} + +// NewWorkItemConfigurationsClientWithBaseURI creates an instance of the WorkItemConfigurationsClient client. +func NewWorkItemConfigurationsClientWithBaseURI(baseURI string, subscriptionID string, purgeID string) WorkItemConfigurationsClient { + return WorkItemConfigurationsClient{NewWithBaseURI(baseURI, subscriptionID, purgeID)} +} + +// Create create a work item configuration for an Application Insights component. +// +// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights +// component resource. workItemConfigurationProperties is properties that need to be specified to create a work +// item configuration of a Application Insights component. +func (client WorkItemConfigurationsClient) Create(ctx context.Context, resourceGroupName string, resourceName string, workItemConfigurationProperties WorkItemCreateConfiguration) (result WorkItemConfiguration, err error) { + req, err := client.CreatePreparer(ctx, resourceGroupName, resourceName, workItemConfigurationProperties) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkItemConfigurationsClient", "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.WorkItemConfigurationsClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkItemConfigurationsClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client WorkItemConfigurationsClient) CreatePreparer(ctx context.Context, resourceGroupName string, resourceName string, workItemConfigurationProperties WorkItemCreateConfiguration) (*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}/WorkItemConfigs", pathParameters), + autorest.WithJSON(workItemConfigurationProperties), + 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 WorkItemConfigurationsClient) 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 WorkItemConfigurationsClient) CreateResponder(resp *http.Response) (result WorkItemConfiguration, 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 workitem configuration of an Application Insights component. +// +// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights +// component resource. workItemConfigID is the unique work item configuration Id. This can be either friendly name +// of connector as defined in connector configuration +func (client WorkItemConfigurationsClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, workItemConfigID string) (result SetObject, err error) { + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName, workItemConfigID) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkItemConfigurationsClient", "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.WorkItemConfigurationsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkItemConfigurationsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client WorkItemConfigurationsClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string, workItemConfigID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workItemConfigId": autorest.Encode("path", workItemConfigID), + } + + 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}/WorkItemConfigs/{workItemConfigId}", 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 WorkItemConfigurationsClient) 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 WorkItemConfigurationsClient) DeleteResponder(resp *http.Response) (result SetObject, 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 +} + +// GetDefault gets default work item configurations that exist for the application +// +// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights +// component resource. +func (client WorkItemConfigurationsClient) GetDefault(ctx context.Context, resourceGroupName string, resourceName string) (result WorkItemConfiguration, err error) { + req, err := client.GetDefaultPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkItemConfigurationsClient", "GetDefault", nil, "Failure preparing request") + return + } + + resp, err := client.GetDefaultSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.WorkItemConfigurationsClient", "GetDefault", resp, "Failure sending request") + return + } + + result, err = client.GetDefaultResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkItemConfigurationsClient", "GetDefault", resp, "Failure responding to request") + } + + return +} + +// GetDefaultPreparer prepares the GetDefault request. +func (client WorkItemConfigurationsClient) GetDefaultPreparer(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}/DefaultWorkItemConfig", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetDefaultSender sends the GetDefault request. The method will close the +// http.Response Body if it receives an error. +func (client WorkItemConfigurationsClient) GetDefaultSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetDefaultResponder handles the response to the GetDefault request. The method always +// closes the http.Response Body. +func (client WorkItemConfigurationsClient) GetDefaultResponder(resp *http.Response) (result WorkItemConfiguration, 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 the list work item configurations that exist for the application +// +// resourceGroupName is the name of the resource group. resourceName is the name of the Application Insights +// component resource. +func (client WorkItemConfigurationsClient) List(ctx context.Context, resourceGroupName string, resourceName string) (result ListWorkItemConfiguration, err error) { + req, err := client.ListPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkItemConfigurationsClient", "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.WorkItemConfigurationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkItemConfigurationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client WorkItemConfigurationsClient) 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}/WorkItemConfigs", 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 WorkItemConfigurationsClient) 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 WorkItemConfigurationsClient) ListResponder(resp *http.Response) (result ListWorkItemConfiguration, 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 +}