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..817a7bcef23f 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,34 @@ 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"` +} + +// 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 { @@ -680,3 +739,51 @@ func (future WorkspacesGetSearchResultsFuture) Result(client WorkspacesClient) ( } return } + +// 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 WorkspacesPurgeFuture) Result(client WorkspacesClient) (so SetObject, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesPurgeFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + return so, azure.NewAsyncOpIncompleteError("operationalinsights.WorkspacesPurgeFuture") + } + if future.PollingMethod() == azure.PollingLocation { + so, err = client.PurgeResponder(future.Response()) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesPurgeFuture", "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.WorkspacesPurgeFuture", "Result", resp, "Failure sending request") + return + } + so, err = client.PurgeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "operationalinsights.WorkspacesPurgeFuture", "Result", resp, "Failure responding to request") + } + return +} 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/workspaces.go b/services/operationalinsights/mgmt/2015-03-20/operationalinsights/workspaces.go index 8ca168f1e1d1..98ffd0e5edff 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. @@ -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 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" }