From 615a89351f083361381c2baa6bc0b6d732a5b952 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Fri, 9 Mar 2018 11:02:54 -0800 Subject: [PATCH 1/2] [AutoPR operationalinsights/resource-manager] Adding OperationalInsights Purge, PurgeStatus operations (#1154) * Generated from d529c8b86ecfad341936b80474ee89057a242d82 Adding OperationalInsights Purge, PurgeStatus operations * Generated from 58b88b90a7c07420de51e0bbb45fd944f6a6601e Modifying long running operation * Generated from 58b88b90a7c07420de51e0bbb45fd944f6a6601e Modifying long running operation --- .../2015-03-20/operationalinsights/client.go | 8 +- .../2015-03-20/operationalinsights/models.go | 107 +++++++++++++++ .../operationalinsights/operations.go | 8 +- .../operationalinsights/savedsearches.go | 8 +- .../operationalinsights/storageinsights.go | 8 +- .../2015-03-20/operationalinsights/version.go | 6 +- .../operationalinsights/workspace.go | 124 ++++++++++++++++++ .../operationalinsights/workspaces.go | 8 +- .../operationalinsights/models.go | 15 +++ .../operationalinsights/version.go | 6 +- 10 files changed, 271 insertions(+), 27 deletions(-) create mode 100644 services/operationalinsights/mgmt/2015-03-20/operationalinsights/workspace.go diff --git a/services/operationalinsights/mgmt/2015-03-20/operationalinsights/client.go b/services/operationalinsights/mgmt/2015-03-20/operationalinsights/client.go index 024b10ca9f3c..187545849d14 100644 --- a/services/operationalinsights/mgmt/2015-03-20/operationalinsights/client.go +++ b/services/operationalinsights/mgmt/2015-03-20/operationalinsights/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/operationalinsights/mgmt/2015-03-20/operationalinsights/models.go b/services/operationalinsights/mgmt/2015-03-20/operationalinsights/models.go index eb9e18342a57..3130d0b0ce7b 100644 --- a/services/operationalinsights/mgmt/2015-03-20/operationalinsights/models.go +++ b/services/operationalinsights/mgmt/2015-03-20/operationalinsights/models.go @@ -26,6 +26,21 @@ import ( "net/http" ) +// PurgeState enumerates the values for purge state. +type PurgeState string + +const ( + // Completed ... + Completed PurgeState = "Completed" + // Pending ... + Pending PurgeState = "Pending" +) + +// PossiblePurgeStateValues returns an array of possible values for the PurgeState const type. +func PossiblePurgeStateValues() [2]PurgeState { + return [2]PurgeState{Completed, Pending} +} + // SearchSortEnum enumerates the values for search sort enum. type SearchSortEnum string @@ -36,6 +51,11 @@ const ( Desc SearchSortEnum = "desc" ) +// PossibleSearchSortEnumValues returns an array of possible values for the SearchSortEnum const type. +func PossibleSearchSortEnumValues() [2]SearchSortEnum { + return [2]SearchSortEnum{Asc, Desc} +} + // StorageInsightState enumerates the values for storage insight state. type StorageInsightState string @@ -46,6 +66,11 @@ const ( OK StorageInsightState = "OK" ) +// PossibleStorageInsightStateValues returns an array of possible values for the StorageInsightState const type. +func PossibleStorageInsightStateValues() [2]StorageInsightState { + return [2]StorageInsightState{ERROR, OK} +} + // CoreSummary the core summary of a search. type CoreSummary struct { // Status - The status of a core summary. @@ -384,6 +409,12 @@ type SearchSort struct { Order SearchSortEnum `json:"order,omitempty"` } +// SetObject ... +type SetObject struct { + autorest.Response `json:"-"` + Value interface{} `json:"value,omitempty"` +} + // StorageAccount describes a storage account connection. type StorageAccount struct { // ID - The Azure Resource Manager ID of the storage account resource. @@ -632,6 +663,82 @@ type Tag struct { Value *string `json:"value,omitempty"` } +// WorkspacePurgeBody describes the body of a purge request for an App Insights Workspace +type WorkspacePurgeBody 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 *[]WorkspacePurgeBodyFilters `json:"filters,omitempty"` +} + +// WorkspacePurgeBodyFilters user-defined filters to return data which will be purged from the table. +type WorkspacePurgeBodyFilters 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"` +} + +// WorkspacePurgeFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type WorkspacePurgeFuture struct { + azure.Future + req *http.Request +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future WorkspacePurgeFuture) Result(client WorkspaceClient) (so SetObject, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacePurgeFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return so, azure.NewAsyncOpIncompleteError("operationalinsights.WorkspacePurgeFuture") + } + if future.PollingMethod() == azure.PollingLocation { + so, err = client.PurgeResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacePurgeFuture", "Result", future.Response(), "Failure responding to request") + } + return + } + var req *http.Request + var resp *http.Response + if future.PollingURL() != "" { + req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil) + if err != nil { + return + } + } else { + req = autorest.ChangeToGet(future.req) + } + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacePurgeFuture", "Result", resp, "Failure sending request") + return + } + so, err = client.PurgeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacePurgeFuture", "Result", resp, "Failure responding to request") + } + return +} + +// WorkspacePurgeResponse response containing operationId for a specific purge action. +type WorkspacePurgeResponse struct { + // OperationID - Id to use when querying for status for a particular purge operation. + OperationID *string `json:"operationId,omitempty"` +} + +// WorkspacePurgeStatusResponse response containing status for a specific purge operation. +type WorkspacePurgeStatusResponse struct { + // Status - Status of the operation represented by the requested Id. Possible values include: 'Pending', 'Completed' + Status PurgeState `json:"status,omitempty"` +} + // WorkspacesGetSearchResultsFuture an abstraction for monitoring and retrieving the results of a long-running // operation. type WorkspacesGetSearchResultsFuture struct { diff --git a/services/operationalinsights/mgmt/2015-03-20/operationalinsights/operations.go b/services/operationalinsights/mgmt/2015-03-20/operationalinsights/operations.go index 8dc20c298bd3..d0951e780577 100644 --- a/services/operationalinsights/mgmt/2015-03-20/operationalinsights/operations.go +++ b/services/operationalinsights/mgmt/2015-03-20/operationalinsights/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 OperationalInsights Rest API operations. diff --git a/services/operationalinsights/mgmt/2015-03-20/operationalinsights/savedsearches.go b/services/operationalinsights/mgmt/2015-03-20/operationalinsights/savedsearches.go index b4f27f705775..1cbe3b51b24c 100644 --- a/services/operationalinsights/mgmt/2015-03-20/operationalinsights/savedsearches.go +++ b/services/operationalinsights/mgmt/2015-03-20/operationalinsights/savedsearches.go @@ -31,13 +31,13 @@ type SavedSearchesClient struct { } // NewSavedSearchesClient creates an instance of the SavedSearchesClient client. -func NewSavedSearchesClient(subscriptionID string) SavedSearchesClient { - return NewSavedSearchesClientWithBaseURI(DefaultBaseURI, subscriptionID) +func NewSavedSearchesClient(subscriptionID string, purgeID string) SavedSearchesClient { + return NewSavedSearchesClientWithBaseURI(DefaultBaseURI, subscriptionID, purgeID) } // NewSavedSearchesClientWithBaseURI creates an instance of the SavedSearchesClient client. -func NewSavedSearchesClientWithBaseURI(baseURI string, subscriptionID string) SavedSearchesClient { - return SavedSearchesClient{NewWithBaseURI(baseURI, subscriptionID)} +func NewSavedSearchesClientWithBaseURI(baseURI string, subscriptionID string, purgeID string) SavedSearchesClient { + return SavedSearchesClient{NewWithBaseURI(baseURI, subscriptionID, purgeID)} } // CreateOrUpdate creates or updates a saved search for a given workspace. diff --git a/services/operationalinsights/mgmt/2015-03-20/operationalinsights/storageinsights.go b/services/operationalinsights/mgmt/2015-03-20/operationalinsights/storageinsights.go index 41fbf15cbd7d..5ad0c86bf5dc 100644 --- a/services/operationalinsights/mgmt/2015-03-20/operationalinsights/storageinsights.go +++ b/services/operationalinsights/mgmt/2015-03-20/operationalinsights/storageinsights.go @@ -31,13 +31,13 @@ type StorageInsightsClient struct { } // NewStorageInsightsClient creates an instance of the StorageInsightsClient client. -func NewStorageInsightsClient(subscriptionID string) StorageInsightsClient { - return NewStorageInsightsClientWithBaseURI(DefaultBaseURI, subscriptionID) +func NewStorageInsightsClient(subscriptionID string, purgeID string) StorageInsightsClient { + return NewStorageInsightsClientWithBaseURI(DefaultBaseURI, subscriptionID, purgeID) } // NewStorageInsightsClientWithBaseURI creates an instance of the StorageInsightsClient client. -func NewStorageInsightsClientWithBaseURI(baseURI string, subscriptionID string) StorageInsightsClient { - return StorageInsightsClient{NewWithBaseURI(baseURI, subscriptionID)} +func NewStorageInsightsClientWithBaseURI(baseURI string, subscriptionID string, purgeID string) StorageInsightsClient { + return StorageInsightsClient{NewWithBaseURI(baseURI, subscriptionID, purgeID)} } // CreateOrUpdate create or update a storage insight. diff --git a/services/operationalinsights/mgmt/2015-03-20/operationalinsights/version.go b/services/operationalinsights/mgmt/2015-03-20/operationalinsights/version.go index b4142180b557..64f80977d94d 100644 --- a/services/operationalinsights/mgmt/2015-03-20/operationalinsights/version.go +++ b/services/operationalinsights/mgmt/2015-03-20/operationalinsights/version.go @@ -1,7 +1,5 @@ package operationalinsights -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 + " operationalinsights/2015-03-20" + 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/operationalinsights/mgmt/2015-03-20/operationalinsights/workspace.go b/services/operationalinsights/mgmt/2015-03-20/operationalinsights/workspace.go new file mode 100644 index 000000000000..6b82aae66b25 --- /dev/null +++ b/services/operationalinsights/mgmt/2015-03-20/operationalinsights/workspace.go @@ -0,0 +1,124 @@ +package operationalinsights + +// 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" +) + +// WorkspaceClient is the operational Insights Client +type WorkspaceClient struct { + BaseClient +} + +// NewWorkspaceClient creates an instance of the WorkspaceClient client. +func NewWorkspaceClient(subscriptionID string, purgeID string) WorkspaceClient { + return NewWorkspaceClientWithBaseURI(DefaultBaseURI, subscriptionID, purgeID) +} + +// NewWorkspaceClientWithBaseURI creates an instance of the WorkspaceClient client. +func NewWorkspaceClientWithBaseURI(baseURI string, subscriptionID string, purgeID string) WorkspaceClient { + return WorkspaceClient{NewWithBaseURI(baseURI, subscriptionID, purgeID)} +} + +// Purge purges data in an Log Analytics workspace by a set of user-defined filters. +// +// resourceGroupName is the name of the resource group to get. The name is case insensitive. workspaceName is log +// Analytics workspace name body is describes the body of a request to purge data in a single table of an Log +// Analytics Workspace +func (client WorkspaceClient) Purge(ctx context.Context, resourceGroupName string, workspaceName string, body WorkspacePurgeBody) (result WorkspacePurgeFuture, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {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("operationalinsights.WorkspaceClient", "Purge", err.Error()) + } + + req, err := client.PurgePreparer(ctx, resourceGroupName, workspaceName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspaceClient", "Purge", nil, "Failure preparing request") + return + } + + result, err = client.PurgeSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspaceClient", "Purge", result.Response(), "Failure sending request") + return + } + + return +} + +// PurgePreparer prepares the Purge request. +func (client WorkspaceClient) PurgePreparer(ctx context.Context, resourceGroupName string, workspaceName string, body WorkspacePurgeBody) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2015-03-20" + 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.OperationalInsights/workspaces/{workspaceName}/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 WorkspaceClient) PurgeSender(req *http.Request) (future WorkspacePurgeFuture, err error) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// PurgeResponder handles the response to the Purge request. The method always +// closes the http.Response Body. +func (client WorkspaceClient) PurgeResponder(resp *http.Response) (result SetObject, 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 +} diff --git a/services/operationalinsights/mgmt/2015-03-20/operationalinsights/workspaces.go b/services/operationalinsights/mgmt/2015-03-20/operationalinsights/workspaces.go index 8ca168f1e1d1..b769317781b0 100644 --- a/services/operationalinsights/mgmt/2015-03-20/operationalinsights/workspaces.go +++ b/services/operationalinsights/mgmt/2015-03-20/operationalinsights/workspaces.go @@ -31,13 +31,13 @@ type WorkspacesClient struct { } // NewWorkspacesClient creates an instance of the WorkspacesClient client. -func NewWorkspacesClient(subscriptionID string) WorkspacesClient { - return NewWorkspacesClientWithBaseURI(DefaultBaseURI, subscriptionID) +func NewWorkspacesClient(subscriptionID string, purgeID string) WorkspacesClient { + return NewWorkspacesClientWithBaseURI(DefaultBaseURI, subscriptionID, purgeID) } // NewWorkspacesClientWithBaseURI creates an instance of the WorkspacesClient client. -func NewWorkspacesClientWithBaseURI(baseURI string, subscriptionID string) WorkspacesClient { - return WorkspacesClient{NewWithBaseURI(baseURI, subscriptionID)} +func NewWorkspacesClientWithBaseURI(baseURI string, subscriptionID string, purgeID string) WorkspacesClient { + return WorkspacesClient{NewWithBaseURI(baseURI, subscriptionID, purgeID)} } // GetSchema gets the schema for a given workspace. diff --git a/services/operationalinsights/mgmt/2015-11-01-preview/operationalinsights/models.go b/services/operationalinsights/mgmt/2015-11-01-preview/operationalinsights/models.go index a7f320479fe6..161e0bc9b89c 100644 --- a/services/operationalinsights/mgmt/2015-11-01-preview/operationalinsights/models.go +++ b/services/operationalinsights/mgmt/2015-11-01-preview/operationalinsights/models.go @@ -62,6 +62,11 @@ const ( WindowsPerformanceCounter DataSourceKind = "WindowsPerformanceCounter" ) +// PossibleDataSourceKindValues returns an array of possible values for the DataSourceKind const type. +func PossibleDataSourceKindValues() [15]DataSourceKind { + return [15]DataSourceKind{AzureActivityLog, ChangeTrackingCustomRegistry, ChangeTrackingDefaultPath, ChangeTrackingDefaultRegistry, ChangeTrackingPath, CustomLog, CustomLogCollection, GenericDataSource, IISLogs, LinuxPerformanceCollection, LinuxPerformanceObject, LinuxSyslog, LinuxSyslogCollection, WindowsEvent, WindowsPerformanceCounter} +} + // EntityStatus enumerates the values for entity status. type EntityStatus string @@ -80,6 +85,11 @@ const ( Succeeded EntityStatus = "Succeeded" ) +// PossibleEntityStatusValues returns an array of possible values for the EntityStatus const type. +func PossibleEntityStatusValues() [6]EntityStatus { + return [6]EntityStatus{Canceled, Creating, Deleting, Failed, ProvisioningAccount, Succeeded} +} + // SkuNameEnum enumerates the values for sku name enum. type SkuNameEnum string @@ -98,6 +108,11 @@ const ( Unlimited SkuNameEnum = "Unlimited" ) +// PossibleSkuNameEnumValues returns an array of possible values for the SkuNameEnum const type. +func PossibleSkuNameEnumValues() [6]SkuNameEnum { + return [6]SkuNameEnum{Free, PerNode, Premium, Standalone, Standard, Unlimited} +} + // DataSource datasources under OMS Workspace. type DataSource struct { autorest.Response `json:"-"` diff --git a/services/operationalinsights/mgmt/2015-11-01-preview/operationalinsights/version.go b/services/operationalinsights/mgmt/2015-11-01-preview/operationalinsights/version.go index d15046da501b..64f80977d94d 100644 --- a/services/operationalinsights/mgmt/2015-11-01-preview/operationalinsights/version.go +++ b/services/operationalinsights/mgmt/2015-11-01-preview/operationalinsights/version.go @@ -1,7 +1,5 @@ package operationalinsights -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 + " operationalinsights/2015-11-01-preview" + 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" } From a9c675f7d4810d3854c583af9a2da08585dfa2b7 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Tue, 13 Mar 2018 15:45:33 -0700 Subject: [PATCH 2/2] Generated from d7605fc339fd7d135d0d742f49220949d5fb0706 (#1235) Fix generated doc structure --- .../2015-03-20/operationalinsights/models.go | 66 +++++----- .../operationalinsights/workspace.go | 124 ------------------ .../operationalinsights/workspaces.go | 83 ++++++++++++ 3 files changed, 116 insertions(+), 157 deletions(-) delete mode 100644 services/operationalinsights/mgmt/2015-03-20/operationalinsights/workspace.go diff --git a/services/operationalinsights/mgmt/2015-03-20/operationalinsights/models.go b/services/operationalinsights/mgmt/2015-03-20/operationalinsights/models.go index 3130d0b0ce7b..817a7bcef23f 100644 --- a/services/operationalinsights/mgmt/2015-03-20/operationalinsights/models.go +++ b/services/operationalinsights/mgmt/2015-03-20/operationalinsights/models.go @@ -679,28 +679,41 @@ type WorkspacePurgeBodyFilters struct { Filter *string `json:"filter,omitempty"` } -// WorkspacePurgeFuture an abstraction for monitoring and retrieving the results of a long-running operation. -type WorkspacePurgeFuture struct { +// WorkspacePurgeResponse response containing operationId for a specific purge action. +type WorkspacePurgeResponse struct { + // OperationID - Id to use when querying for status for a particular purge operation. + OperationID *string `json:"operationId,omitempty"` +} + +// WorkspacePurgeStatusResponse response containing status for a specific purge operation. +type WorkspacePurgeStatusResponse struct { + // Status - Status of the operation represented by the requested Id. Possible values include: 'Pending', 'Completed' + Status PurgeState `json:"status,omitempty"` +} + +// WorkspacesGetSearchResultsFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type WorkspacesGetSearchResultsFuture struct { azure.Future req *http.Request } // Result returns the result of the asynchronous operation. // If the operation has not completed it will return an error. -func (future WorkspacePurgeFuture) Result(client WorkspaceClient) (so SetObject, err error) { +func (future WorkspacesGetSearchResultsFuture) Result(client WorkspacesClient) (srr SearchResultsResponse, err error) { var done bool done, err = future.Done(client) if err != nil { - err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacePurgeFuture", "Result", future.Response(), "Polling failure") + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesGetSearchResultsFuture", "Result", future.Response(), "Polling failure") return } if !done { - return so, azure.NewAsyncOpIncompleteError("operationalinsights.WorkspacePurgeFuture") + return srr, azure.NewAsyncOpIncompleteError("operationalinsights.WorkspacesGetSearchResultsFuture") } if future.PollingMethod() == azure.PollingLocation { - so, err = client.PurgeResponder(future.Response()) + srr, err = client.GetSearchResultsResponder(future.Response()) if err != nil { - err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacePurgeFuture", "Result", future.Response(), "Failure responding to request") + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesGetSearchResultsFuture", "Result", future.Response(), "Failure responding to request") } return } @@ -717,51 +730,38 @@ func (future WorkspacePurgeFuture) Result(client WorkspaceClient) (so SetObject, resp, err = autorest.SendWithSender(client, req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { - err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacePurgeFuture", "Result", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesGetSearchResultsFuture", "Result", resp, "Failure sending request") return } - so, err = client.PurgeResponder(resp) + srr, err = client.GetSearchResultsResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacePurgeFuture", "Result", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesGetSearchResultsFuture", "Result", resp, "Failure responding to request") } return } -// WorkspacePurgeResponse response containing operationId for a specific purge action. -type WorkspacePurgeResponse struct { - // OperationID - Id to use when querying for status for a particular purge operation. - OperationID *string `json:"operationId,omitempty"` -} - -// WorkspacePurgeStatusResponse response containing status for a specific purge operation. -type WorkspacePurgeStatusResponse struct { - // Status - Status of the operation represented by the requested Id. Possible values include: 'Pending', 'Completed' - Status PurgeState `json:"status,omitempty"` -} - -// WorkspacesGetSearchResultsFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type WorkspacesGetSearchResultsFuture struct { +// WorkspacesPurgeFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type WorkspacesPurgeFuture struct { azure.Future req *http.Request } // Result returns the result of the asynchronous operation. // If the operation has not completed it will return an error. -func (future WorkspacesGetSearchResultsFuture) Result(client WorkspacesClient) (srr SearchResultsResponse, err error) { +func (future WorkspacesPurgeFuture) Result(client WorkspacesClient) (so SetObject, err error) { var done bool done, err = future.Done(client) if err != nil { - err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesGetSearchResultsFuture", "Result", future.Response(), "Polling failure") + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesPurgeFuture", "Result", future.Response(), "Polling failure") return } if !done { - return srr, azure.NewAsyncOpIncompleteError("operationalinsights.WorkspacesGetSearchResultsFuture") + return so, azure.NewAsyncOpIncompleteError("operationalinsights.WorkspacesPurgeFuture") } if future.PollingMethod() == azure.PollingLocation { - srr, err = client.GetSearchResultsResponder(future.Response()) + so, err = client.PurgeResponder(future.Response()) if err != nil { - err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesGetSearchResultsFuture", "Result", future.Response(), "Failure responding to request") + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesPurgeFuture", "Result", future.Response(), "Failure responding to request") } return } @@ -778,12 +778,12 @@ func (future WorkspacesGetSearchResultsFuture) Result(client WorkspacesClient) ( resp, err = autorest.SendWithSender(client, req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) if err != nil { - err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesGetSearchResultsFuture", "Result", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesPurgeFuture", "Result", resp, "Failure sending request") return } - srr, err = client.GetSearchResultsResponder(resp) + so, err = client.PurgeResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesGetSearchResultsFuture", "Result", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesPurgeFuture", "Result", resp, "Failure responding to request") } return } diff --git a/services/operationalinsights/mgmt/2015-03-20/operationalinsights/workspace.go b/services/operationalinsights/mgmt/2015-03-20/operationalinsights/workspace.go deleted file mode 100644 index 6b82aae66b25..000000000000 --- a/services/operationalinsights/mgmt/2015-03-20/operationalinsights/workspace.go +++ /dev/null @@ -1,124 +0,0 @@ -package operationalinsights - -// 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" -) - -// WorkspaceClient is the operational Insights Client -type WorkspaceClient struct { - BaseClient -} - -// NewWorkspaceClient creates an instance of the WorkspaceClient client. -func NewWorkspaceClient(subscriptionID string, purgeID string) WorkspaceClient { - return NewWorkspaceClientWithBaseURI(DefaultBaseURI, subscriptionID, purgeID) -} - -// NewWorkspaceClientWithBaseURI creates an instance of the WorkspaceClient client. -func NewWorkspaceClientWithBaseURI(baseURI string, subscriptionID string, purgeID string) WorkspaceClient { - return WorkspaceClient{NewWithBaseURI(baseURI, subscriptionID, purgeID)} -} - -// Purge purges data in an Log Analytics workspace by a set of user-defined filters. -// -// resourceGroupName is the name of the resource group to get. The name is case insensitive. workspaceName is log -// Analytics workspace name body is describes the body of a request to purge data in a single table of an Log -// Analytics Workspace -func (client WorkspaceClient) Purge(ctx context.Context, resourceGroupName string, workspaceName string, body WorkspacePurgeBody) (result WorkspacePurgeFuture, err error) { - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, - {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("operationalinsights.WorkspaceClient", "Purge", err.Error()) - } - - req, err := client.PurgePreparer(ctx, resourceGroupName, workspaceName, body) - if err != nil { - err = autorest.NewErrorWithError(err, "operationalinsights.WorkspaceClient", "Purge", nil, "Failure preparing request") - return - } - - result, err = client.PurgeSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "operationalinsights.WorkspaceClient", "Purge", result.Response(), "Failure sending request") - return - } - - return -} - -// PurgePreparer prepares the Purge request. -func (client WorkspaceClient) PurgePreparer(ctx context.Context, resourceGroupName string, workspaceName string, body WorkspacePurgeBody) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "workspaceName": autorest.Encode("path", workspaceName), - } - - const APIVersion = "2015-03-20" - 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.OperationalInsights/workspaces/{workspaceName}/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 WorkspaceClient) PurgeSender(req *http.Request) (future WorkspacePurgeFuture, err error) { - sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) - future.Future = azure.NewFuture(req) - future.req = req - _, err = future.Done(sender) - if err != nil { - return - } - err = autorest.Respond(future.Response(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) - return -} - -// PurgeResponder handles the response to the Purge request. The method always -// closes the http.Response Body. -func (client WorkspaceClient) PurgeResponder(resp *http.Response) (result SetObject, 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 -} diff --git a/services/operationalinsights/mgmt/2015-03-20/operationalinsights/workspaces.go b/services/operationalinsights/mgmt/2015-03-20/operationalinsights/workspaces.go index b769317781b0..98ffd0e5edff 100644 --- a/services/operationalinsights/mgmt/2015-03-20/operationalinsights/workspaces.go +++ b/services/operationalinsights/mgmt/2015-03-20/operationalinsights/workspaces.go @@ -261,6 +261,89 @@ func (client WorkspacesClient) ListLinkTargetsResponder(resp *http.Response) (re return } +// Purge purges data in an Log Analytics workspace by a set of user-defined filters. +// +// resourceGroupName is the name of the resource group to get. The name is case insensitive. workspaceName is log +// Analytics workspace name body is describes the body of a request to purge data in a single table of an Log +// Analytics Workspace +func (client WorkspacesClient) Purge(ctx context.Context, resourceGroupName string, workspaceName string, body WorkspacePurgeBody) (result WorkspacesPurgeFuture, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {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("operationalinsights.WorkspacesClient", "Purge", err.Error()) + } + + req, err := client.PurgePreparer(ctx, resourceGroupName, workspaceName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesClient", "Purge", nil, "Failure preparing request") + return + } + + result, err = client.PurgeSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesClient", "Purge", result.Response(), "Failure sending request") + return + } + + return +} + +// PurgePreparer prepares the Purge request. +func (client WorkspacesClient) PurgePreparer(ctx context.Context, resourceGroupName string, workspaceName string, body WorkspacePurgeBody) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2015-03-20" + 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.OperationalInsights/workspaces/{workspaceName}/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 WorkspacesClient) PurgeSender(req *http.Request) (future WorkspacesPurgeFuture, err error) { + sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client)) + future.Future = azure.NewFuture(req) + future.req = req + _, err = future.Done(sender) + if err != nil { + return + } + err = autorest.Respond(future.Response(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + return +} + +// PurgeResponder handles the response to the Purge request. The method always +// closes the http.Response Body. +func (client WorkspacesClient) PurgeResponder(resp *http.Response) (result SetObject, 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 +} + // UpdateSearchResults gets updated search results for a given search query. // // resourceGroupName is the name of the resource group to get. The name is case insensitive. workspaceName is log