diff --git a/sdk/operationalinsights/armoperationalinsights/CHANGELOG.md b/sdk/operationalinsights/armoperationalinsights/CHANGELOG.md new file mode 100644 index 000000000000..c7196df9ed8b --- /dev/null +++ b/sdk/operationalinsights/armoperationalinsights/CHANGELOG.md @@ -0,0 +1,3 @@ +# Release History + +## v0.1.0 (released) diff --git a/sdk/operationalinsights/armoperationalinsights/LICENSE.txt b/sdk/operationalinsights/armoperationalinsights/LICENSE.txt new file mode 100644 index 000000000000..ccb63b166732 --- /dev/null +++ b/sdk/operationalinsights/armoperationalinsights/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2021 Microsoft + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/sdk/operationalinsights/armoperationalinsights/README.md b/sdk/operationalinsights/armoperationalinsights/README.md new file mode 100644 index 000000000000..8012ccb759bb --- /dev/null +++ b/sdk/operationalinsights/armoperationalinsights/README.md @@ -0,0 +1,76 @@ +# Azure Operational Insights Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/operationalinsights/armoperationalinsights)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/operationalinsights/armoperationalinsights) + +The `armoperationalinsights` module provides operations for working with Azure Operational Insights. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/operationalinsights/armoperationalinsights) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.13 or above + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Operational Insights module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/operationalinsights/armoperationalinsights +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Operational Insights. The `azidentity` module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more. + +```go +cred, err := azidentity.NewDefaultAzureCredential(nil) +``` + +For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). + +## Connecting to Azure Operational Insights + +Once you have a credential, create a connection to the desired ARM endpoint. The `armcore` module provides facilities for connecting with ARM endpoints including public and sovereign clouds as well as Azure Stack. + +```go +con := armcore.NewDefaultConnection(cred, nil) +``` + +For more information on ARM connections, please see the documentation for `armcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/armcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/armcore). + +## Clients + +Azure Operational Insights modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your `armcore.Connection`. + +```go +client := armoperationalinsights.NewOperationsClient(con, "") +``` + +## Provide Feedback + +If you encounter bugs or have suggestions, please +[open an issue](https://github.com/Azure/azure-sdk-for-go/issues) and assign the `Operational Insights` label. + +# Contributing + +This project welcomes contributions and suggestions. Most contributions require +you to agree to a Contributor License Agreement (CLA) declaring that you have +the right to, and actually do, grant us the rights to use your contribution. +For details, visit [https://cla.microsoft.com](https://cla.microsoft.com). + +When you submit a pull request, a CLA-bot will automatically determine whether +you need to provide a CLA and decorate the PR appropriately (e.g., label, +comment). Simply follow the instructions provided by the bot. You will only +need to do this once across all repos using our CLA. + +This project has adopted the +[Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +For more information, see the +[Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) +or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any +additional questions or comments. \ No newline at end of file diff --git a/sdk/operationalinsights/armoperationalinsights/autorest.md b/sdk/operationalinsights/armoperationalinsights/autorest.md new file mode 100644 index 000000000000..59bfcd655524 --- /dev/null +++ b/sdk/operationalinsights/armoperationalinsights/autorest.md @@ -0,0 +1,10 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +require: +- https://github.com/Azure/azure-rest-api-specs/blob/8b708ea0e665144ad1fe691fc7cca33517ac3c7e/specification/operationalinsights/resource-manager/readme.md +- https://github.com/Azure/azure-rest-api-specs/blob/8b708ea0e665144ad1fe691fc7cca33517ac3c7e/specification/operationalinsights/resource-manager/readme.go.md +module-version: 0.1.0 +``` \ No newline at end of file diff --git a/sdk/operationalinsights/armoperationalinsights/build.go b/sdk/operationalinsights/armoperationalinsights/build.go new file mode 100644 index 000000000000..3886c1bd56b3 --- /dev/null +++ b/sdk/operationalinsights/armoperationalinsights/build.go @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file enables 'go generate' to regenerate this specific SDK +//go:generate pwsh.exe ../../../eng/scripts/build.ps1 -skipBuild -format -tidy -generate armoperationalinsights + +package armoperationalinsights diff --git a/sdk/operationalinsights/armoperationalinsights/ci.yml b/sdk/operationalinsights/armoperationalinsights/ci.yml new file mode 100644 index 000000000000..8945c54e0c49 --- /dev/null +++ b/sdk/operationalinsights/armoperationalinsights/ci.yml @@ -0,0 +1,15 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. +trigger: + paths: + include: + - sdk/operationalinsights/armoperationalinsights/ + +pr: + paths: + include: + - sdk/operationalinsights/armoperationalinsights/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'operationalinsights/armoperationalinsights' diff --git a/sdk/operationalinsights/armoperationalinsights/go.mod b/sdk/operationalinsights/armoperationalinsights/go.mod new file mode 100644 index 000000000000..80d3c2d6e4cd --- /dev/null +++ b/sdk/operationalinsights/armoperationalinsights/go.mod @@ -0,0 +1,9 @@ +module github.com/Azure/azure-sdk-for-go/sdk/operationalinsights/armoperationalinsights + +go 1.13 + +require ( + github.com/Azure/azure-sdk-for-go v56.1.0+incompatible + github.com/Azure/azure-sdk-for-go/sdk/armcore v0.8.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v0.16.2 +) diff --git a/sdk/operationalinsights/armoperationalinsights/go.sum b/sdk/operationalinsights/armoperationalinsights/go.sum new file mode 100644 index 000000000000..9e02912957fd --- /dev/null +++ b/sdk/operationalinsights/armoperationalinsights/go.sum @@ -0,0 +1,20 @@ +github.com/Azure/azure-sdk-for-go v56.1.0+incompatible h1:Ofcecdw3F1ZqnpDEZcLzH9Hq0P4Y5Si8+EioXJSamJs= +github.com/Azure/azure-sdk-for-go v56.1.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= +github.com/Azure/azure-sdk-for-go/sdk/armcore v0.8.0 h1:HQQoaSGOh32mpoRkpLDjkngMwYJqkxu93FRx0epdLHE= +github.com/Azure/azure-sdk-for-go/sdk/armcore v0.8.0/go.mod h1:BSKvHb/5cy8j4hahIInXH92X/2zGJ3TxKF6b9pw1Btg= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.16.2 h1:UC4vfOhW2l0f2QOCQpOxJS4/K6oKFy2tQZE+uWU1MEo= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.16.2/go.mod h1:MVdrcUC4Hup35qHym3VdzoW+NBgBxrta9Vei97jRtM8= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.5.1 h1:vx8McI56N5oLSQu8xa+xdiE0fjQq8W8Zt49vHP8Rygw= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.5.1/go.mod h1:k4KbFSunV/+0hOHL1vyFaPsiYQ1Vmvy1TBpmtvCDLZM= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20201010224723-4f7140c49acb h1:mUVeFHoDKis5nxCAzoAi7E8Ghb86EXh/RK6wtvJIqRY= +golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= diff --git a/sdk/operationalinsights/armoperationalinsights/go_mod_tidy_hack.go b/sdk/operationalinsights/armoperationalinsights/go_mod_tidy_hack.go new file mode 100644 index 000000000000..02c599e4426a --- /dev/null +++ b/sdk/operationalinsights/armoperationalinsights/go_mod_tidy_hack.go @@ -0,0 +1,12 @@ +// +build modhack + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file, and the github.com/Azure/azure-sdk-for-go import, won't actually become part of +// the resultant binary. + +package armoperationalinsights + +// Necessary for safely adding multi-module repo. See: https://github.com/golang/go/wiki/Modules#is-it-possible-to-add-a-module-to-a-multi-module-repository +import _ "github.com/Azure/azure-sdk-for-go" diff --git a/sdk/operationalinsights/armoperationalinsights/zz_generated_availableservicetiers_client.go b/sdk/operationalinsights/armoperationalinsights/zz_generated_availableservicetiers_client.go new file mode 100644 index 000000000000..d4e953731704 --- /dev/null +++ b/sdk/operationalinsights/armoperationalinsights/zz_generated_availableservicetiers_client.go @@ -0,0 +1,95 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armoperationalinsights + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// AvailableServiceTiersClient contains the methods for the AvailableServiceTiers group. +// Don't use this type directly, use NewAvailableServiceTiersClient() instead. +type AvailableServiceTiersClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewAvailableServiceTiersClient creates a new instance of AvailableServiceTiersClient with the specified values. +func NewAvailableServiceTiersClient(con *armcore.Connection, subscriptionID string) *AvailableServiceTiersClient { + return &AvailableServiceTiersClient{con: con, subscriptionID: subscriptionID} +} + +// ListByWorkspace - Gets the available service tiers for the workspace. +// If the operation fails it returns a generic error. +func (client *AvailableServiceTiersClient) ListByWorkspace(ctx context.Context, resourceGroupName string, workspaceName string, options *AvailableServiceTiersListByWorkspaceOptions) (AvailableServiceTiersListByWorkspaceResponse, error) { + req, err := client.listByWorkspaceCreateRequest(ctx, resourceGroupName, workspaceName, options) + if err != nil { + return AvailableServiceTiersListByWorkspaceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return AvailableServiceTiersListByWorkspaceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return AvailableServiceTiersListByWorkspaceResponse{}, client.listByWorkspaceHandleError(resp) + } + return client.listByWorkspaceHandleResponse(resp) +} + +// listByWorkspaceCreateRequest creates the ListByWorkspace request. +func (client *AvailableServiceTiersClient) listByWorkspaceCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, options *AvailableServiceTiersListByWorkspaceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/availableServiceTiers" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-08-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByWorkspaceHandleResponse handles the ListByWorkspace response. +func (client *AvailableServiceTiersClient) listByWorkspaceHandleResponse(resp *azcore.Response) (AvailableServiceTiersListByWorkspaceResponse, error) { + result := AvailableServiceTiersListByWorkspaceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.AvailableServiceTierArray); err != nil { + return AvailableServiceTiersListByWorkspaceResponse{}, err + } + return result, nil +} + +// listByWorkspaceHandleError handles the ListByWorkspace error response. +func (client *AvailableServiceTiersClient) listByWorkspaceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} diff --git a/sdk/operationalinsights/armoperationalinsights/zz_generated_clusters_client.go b/sdk/operationalinsights/armoperationalinsights/zz_generated_clusters_client.go new file mode 100644 index 000000000000..df6bba17629a --- /dev/null +++ b/sdk/operationalinsights/armoperationalinsights/zz_generated_clusters_client.go @@ -0,0 +1,488 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armoperationalinsights + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" + "time" +) + +// ClustersClient contains the methods for the Clusters group. +// Don't use this type directly, use NewClustersClient() instead. +type ClustersClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewClustersClient creates a new instance of ClustersClient with the specified values. +func NewClustersClient(con *armcore.Connection, subscriptionID string) *ClustersClient { + return &ClustersClient{con: con, subscriptionID: subscriptionID} +} + +// BeginCreateOrUpdate - Create or update a Log Analytics cluster. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ClustersClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, clusterName string, parameters Cluster, options *ClustersBeginCreateOrUpdateOptions) (ClustersCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, clusterName, parameters, options) + if err != nil { + return ClustersCreateOrUpdatePollerResponse{}, err + } + result := ClustersCreateOrUpdatePollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("ClustersClient.CreateOrUpdate", "", resp, client.con.Pipeline(), client.createOrUpdateHandleError) + if err != nil { + return ClustersCreateOrUpdatePollerResponse{}, err + } + poller := &clustersCreateOrUpdatePoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (ClustersCreateOrUpdateResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeCreateOrUpdate creates a new ClustersCreateOrUpdatePoller from the specified resume token. +// token - The value must come from a previous call to ClustersCreateOrUpdatePoller.ResumeToken(). +func (client *ClustersClient) ResumeCreateOrUpdate(ctx context.Context, token string) (ClustersCreateOrUpdatePollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("ClustersClient.CreateOrUpdate", token, client.con.Pipeline(), client.createOrUpdateHandleError) + if err != nil { + return ClustersCreateOrUpdatePollerResponse{}, err + } + poller := &clustersCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return ClustersCreateOrUpdatePollerResponse{}, err + } + result := ClustersCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (ClustersCreateOrUpdateResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// CreateOrUpdate - Create or update a Log Analytics cluster. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ClustersClient) createOrUpdate(ctx context.Context, resourceGroupName string, clusterName string, parameters Cluster, options *ClustersBeginCreateOrUpdateOptions) (*azcore.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, clusterName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted) { + return nil, client.createOrUpdateHandleError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *ClustersClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, parameters Cluster, options *ClustersBeginCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-10-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *ClustersClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// BeginDelete - Deletes a cluster instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ClustersClient) BeginDelete(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersBeginDeleteOptions) (ClustersDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, clusterName, options) + if err != nil { + return ClustersDeletePollerResponse{}, err + } + result := ClustersDeletePollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("ClustersClient.Delete", "", resp, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return ClustersDeletePollerResponse{}, err + } + poller := &clustersDeletePoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (ClustersDeleteResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeDelete creates a new ClustersDeletePoller from the specified resume token. +// token - The value must come from a previous call to ClustersDeletePoller.ResumeToken(). +func (client *ClustersClient) ResumeDelete(ctx context.Context, token string) (ClustersDeletePollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("ClustersClient.Delete", token, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return ClustersDeletePollerResponse{}, err + } + poller := &clustersDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return ClustersDeletePollerResponse{}, err + } + result := ClustersDeletePollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (ClustersDeleteResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Delete - Deletes a cluster instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ClustersClient) deleteOperation(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersBeginDeleteOptions) (*azcore.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, clusterName, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ClustersClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersBeginDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-10-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *ClustersClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets a Log Analytics cluster instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ClustersClient) Get(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersGetOptions) (ClustersGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, clusterName, options) + if err != nil { + return ClustersGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ClustersGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return ClustersGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ClustersClient) getCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-10-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ClustersClient) getHandleResponse(resp *azcore.Response) (ClustersGetResponse, error) { + result := ClustersGetResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.Cluster); err != nil { + return ClustersGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *ClustersClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// List - Gets the Log Analytics clusters in a subscription. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ClustersClient) List(options *ClustersListOptions) ClustersListPager { + return &clustersListPager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp ClustersListResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.ClusterListResult.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *ClustersClient) listCreateRequest(ctx context.Context, options *ClustersListOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.OperationalInsights/clusters" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-10-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ClustersClient) listHandleResponse(resp *azcore.Response) (ClustersListResponse, error) { + result := ClustersListResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.ClusterListResult); err != nil { + return ClustersListResponse{}, err + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *ClustersClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByResourceGroup - Gets Log Analytics clusters in a resource group. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ClustersClient) ListByResourceGroup(resourceGroupName string, options *ClustersListByResourceGroupOptions) ClustersListByResourceGroupPager { + return &clustersListByResourceGroupPager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, + advancer: func(ctx context.Context, resp ClustersListByResourceGroupResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.ClusterListResult.NextLink) + }, + } +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *ClustersClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ClustersListByResourceGroupOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-10-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *ClustersClient) listByResourceGroupHandleResponse(resp *azcore.Response) (ClustersListByResourceGroupResponse, error) { + result := ClustersListByResourceGroupResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.ClusterListResult); err != nil { + return ClustersListByResourceGroupResponse{}, err + } + return result, nil +} + +// listByResourceGroupHandleError handles the ListByResourceGroup error response. +func (client *ClustersClient) listByResourceGroupHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Update - Updates a Log Analytics cluster. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ClustersClient) Update(ctx context.Context, resourceGroupName string, clusterName string, parameters ClusterPatch, options *ClustersUpdateOptions) (ClustersUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, clusterName, parameters, options) + if err != nil { + return ClustersUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ClustersUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return ClustersUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *ClustersClient) updateCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, parameters ClusterPatch, options *ClustersUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-10-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// updateHandleResponse handles the Update response. +func (client *ClustersClient) updateHandleResponse(resp *azcore.Response) (ClustersUpdateResponse, error) { + result := ClustersUpdateResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.Cluster); err != nil { + return ClustersUpdateResponse{}, err + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *ClustersClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/operationalinsights/armoperationalinsights/zz_generated_constants.go b/sdk/operationalinsights/armoperationalinsights/zz_generated_constants.go new file mode 100644 index 000000000000..098fb71b2de5 --- /dev/null +++ b/sdk/operationalinsights/armoperationalinsights/zz_generated_constants.go @@ -0,0 +1,476 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armoperationalinsights + +const telemetryInfo = "azsdk-go-armoperationalinsights/v0.1.0" + +// BillingType - Configures whether billing will be only on the cluster or each workspace will be billed by its proportional use. This does not change the +// overall billing, only how it will be distributed. Default +// value is 'Cluster' +type BillingType string + +const ( + BillingTypeCluster BillingType = "Cluster" + BillingTypeWorkspaces BillingType = "Workspaces" +) + +// PossibleBillingTypeValues returns the possible values for the BillingType const type. +func PossibleBillingTypeValues() []BillingType { + return []BillingType{ + BillingTypeCluster, + BillingTypeWorkspaces, + } +} + +// ToPtr returns a *BillingType pointing to the current value. +func (c BillingType) ToPtr() *BillingType { + return &c +} + +// ClusterEntityStatus - The provisioning state of the cluster. +type ClusterEntityStatus string + +const ( + ClusterEntityStatusCanceled ClusterEntityStatus = "Canceled" + ClusterEntityStatusCreating ClusterEntityStatus = "Creating" + ClusterEntityStatusDeleting ClusterEntityStatus = "Deleting" + ClusterEntityStatusFailed ClusterEntityStatus = "Failed" + ClusterEntityStatusProvisioningAccount ClusterEntityStatus = "ProvisioningAccount" + ClusterEntityStatusSucceeded ClusterEntityStatus = "Succeeded" + ClusterEntityStatusUpdating ClusterEntityStatus = "Updating" +) + +// PossibleClusterEntityStatusValues returns the possible values for the ClusterEntityStatus const type. +func PossibleClusterEntityStatusValues() []ClusterEntityStatus { + return []ClusterEntityStatus{ + ClusterEntityStatusCanceled, + ClusterEntityStatusCreating, + ClusterEntityStatusDeleting, + ClusterEntityStatusFailed, + ClusterEntityStatusProvisioningAccount, + ClusterEntityStatusSucceeded, + ClusterEntityStatusUpdating, + } +} + +// ToPtr returns a *ClusterEntityStatus pointing to the current value. +func (c ClusterEntityStatus) ToPtr() *ClusterEntityStatus { + return &c +} + +// ClusterSKUNameEnum - The name of the SKU. +type ClusterSKUNameEnum string + +const ( + ClusterSKUNameEnumCapacityReservation ClusterSKUNameEnum = "CapacityReservation" +) + +// PossibleClusterSKUNameEnumValues returns the possible values for the ClusterSKUNameEnum const type. +func PossibleClusterSKUNameEnumValues() []ClusterSKUNameEnum { + return []ClusterSKUNameEnum{ + ClusterSKUNameEnumCapacityReservation, + } +} + +// ToPtr returns a *ClusterSKUNameEnum pointing to the current value. +func (c ClusterSKUNameEnum) ToPtr() *ClusterSKUNameEnum { + return &c +} + +// DataIngestionStatus - The status of data ingestion for this workspace. +type DataIngestionStatus string + +const ( + // DataIngestionStatusApproachingQuota - 80% of daily cap quota reached. + DataIngestionStatusApproachingQuota DataIngestionStatus = "ApproachingQuota" + // DataIngestionStatusForceOff - Ingestion stopped following service setting change. + DataIngestionStatusForceOff DataIngestionStatus = "ForceOff" + // DataIngestionStatusForceOn - Ingestion started following service setting change. + DataIngestionStatusForceOn DataIngestionStatus = "ForceOn" + // DataIngestionStatusOverQuota - Reached daily cap quota, ingestion stopped. + DataIngestionStatusOverQuota DataIngestionStatus = "OverQuota" + // DataIngestionStatusRespectQuota - Ingestion enabled following daily cap quota reset, or subscription enablement. + DataIngestionStatusRespectQuota DataIngestionStatus = "RespectQuota" + // DataIngestionStatusSubscriptionSuspended - Ingestion stopped following suspended subscription. + DataIngestionStatusSubscriptionSuspended DataIngestionStatus = "SubscriptionSuspended" +) + +// PossibleDataIngestionStatusValues returns the possible values for the DataIngestionStatus const type. +func PossibleDataIngestionStatusValues() []DataIngestionStatus { + return []DataIngestionStatus{ + DataIngestionStatusApproachingQuota, + DataIngestionStatusForceOff, + DataIngestionStatusForceOn, + DataIngestionStatusOverQuota, + DataIngestionStatusRespectQuota, + DataIngestionStatusSubscriptionSuspended, + } +} + +// ToPtr returns a *DataIngestionStatus pointing to the current value. +func (c DataIngestionStatus) ToPtr() *DataIngestionStatus { + return &c +} + +// DataSourceKind - The kind of the DataSource. +type DataSourceKind string + +const ( + DataSourceKindApplicationInsights DataSourceKind = "ApplicationInsights" + DataSourceKindAzureActivityLog DataSourceKind = "AzureActivityLog" + DataSourceKindAzureAuditLog DataSourceKind = "AzureAuditLog" + DataSourceKindChangeTrackingContentLocation DataSourceKind = "ChangeTrackingContentLocation" + DataSourceKindChangeTrackingCustomPath DataSourceKind = "ChangeTrackingCustomPath" + DataSourceKindChangeTrackingDataTypeConfiguration DataSourceKind = "ChangeTrackingDataTypeConfiguration" + DataSourceKindChangeTrackingDefaultRegistry DataSourceKind = "ChangeTrackingDefaultRegistry" + DataSourceKindChangeTrackingLinuxPath DataSourceKind = "ChangeTrackingLinuxPath" + DataSourceKindChangeTrackingPath DataSourceKind = "ChangeTrackingPath" + DataSourceKindChangeTrackingRegistry DataSourceKind = "ChangeTrackingRegistry" + DataSourceKindChangeTrackingServices DataSourceKind = "ChangeTrackingServices" + DataSourceKindCustomLog DataSourceKind = "CustomLog" + DataSourceKindCustomLogCollection DataSourceKind = "CustomLogCollection" + DataSourceKindDNSAnalytics DataSourceKind = "DnsAnalytics" + DataSourceKindGenericDataSource DataSourceKind = "GenericDataSource" + DataSourceKindIISLogs DataSourceKind = "IISLogs" + DataSourceKindImportComputerGroup DataSourceKind = "ImportComputerGroup" + DataSourceKindItsm DataSourceKind = "Itsm" + DataSourceKindLinuxChangeTrackingPath DataSourceKind = "LinuxChangeTrackingPath" + DataSourceKindLinuxPerformanceCollection DataSourceKind = "LinuxPerformanceCollection" + DataSourceKindLinuxPerformanceObject DataSourceKind = "LinuxPerformanceObject" + DataSourceKindLinuxSyslog DataSourceKind = "LinuxSyslog" + DataSourceKindLinuxSyslogCollection DataSourceKind = "LinuxSyslogCollection" + DataSourceKindNetworkMonitoring DataSourceKind = "NetworkMonitoring" + DataSourceKindOffice365 DataSourceKind = "Office365" + DataSourceKindSQLDataClassification DataSourceKind = "SqlDataClassification" + DataSourceKindSecurityCenterSecurityWindowsBaselineConfiguration DataSourceKind = "SecurityCenterSecurityWindowsBaselineConfiguration" + DataSourceKindSecurityEventCollectionConfiguration DataSourceKind = "SecurityEventCollectionConfiguration" + DataSourceKindSecurityInsightsSecurityEventCollectionConfiguration DataSourceKind = "SecurityInsightsSecurityEventCollectionConfiguration" + DataSourceKindSecurityWindowsBaselineConfiguration DataSourceKind = "SecurityWindowsBaselineConfiguration" + DataSourceKindWindowsEvent DataSourceKind = "WindowsEvent" + DataSourceKindWindowsPerformanceCounter DataSourceKind = "WindowsPerformanceCounter" + DataSourceKindWindowsTelemetry DataSourceKind = "WindowsTelemetry" +) + +// PossibleDataSourceKindValues returns the possible values for the DataSourceKind const type. +func PossibleDataSourceKindValues() []DataSourceKind { + return []DataSourceKind{ + DataSourceKindApplicationInsights, + DataSourceKindAzureActivityLog, + DataSourceKindAzureAuditLog, + DataSourceKindChangeTrackingContentLocation, + DataSourceKindChangeTrackingCustomPath, + DataSourceKindChangeTrackingDataTypeConfiguration, + DataSourceKindChangeTrackingDefaultRegistry, + DataSourceKindChangeTrackingLinuxPath, + DataSourceKindChangeTrackingPath, + DataSourceKindChangeTrackingRegistry, + DataSourceKindChangeTrackingServices, + DataSourceKindCustomLog, + DataSourceKindCustomLogCollection, + DataSourceKindDNSAnalytics, + DataSourceKindGenericDataSource, + DataSourceKindIISLogs, + DataSourceKindImportComputerGroup, + DataSourceKindItsm, + DataSourceKindLinuxChangeTrackingPath, + DataSourceKindLinuxPerformanceCollection, + DataSourceKindLinuxPerformanceObject, + DataSourceKindLinuxSyslog, + DataSourceKindLinuxSyslogCollection, + DataSourceKindNetworkMonitoring, + DataSourceKindOffice365, + DataSourceKindSQLDataClassification, + DataSourceKindSecurityCenterSecurityWindowsBaselineConfiguration, + DataSourceKindSecurityEventCollectionConfiguration, + DataSourceKindSecurityInsightsSecurityEventCollectionConfiguration, + DataSourceKindSecurityWindowsBaselineConfiguration, + DataSourceKindWindowsEvent, + DataSourceKindWindowsPerformanceCounter, + DataSourceKindWindowsTelemetry, + } +} + +// ToPtr returns a *DataSourceKind pointing to the current value. +func (c DataSourceKind) ToPtr() *DataSourceKind { + return &c +} + +// DataSourceType - Linked storage accounts type. +type DataSourceType string + +const ( + DataSourceTypeCustomLogs DataSourceType = "CustomLogs" + DataSourceTypeAzureWatson DataSourceType = "AzureWatson" + DataSourceTypeQuery DataSourceType = "Query" + DataSourceTypeAlerts DataSourceType = "Alerts" +) + +// PossibleDataSourceTypeValues returns the possible values for the DataSourceType const type. +func PossibleDataSourceTypeValues() []DataSourceType { + return []DataSourceType{ + DataSourceTypeCustomLogs, + DataSourceTypeAzureWatson, + DataSourceTypeQuery, + DataSourceTypeAlerts, + } +} + +// ToPtr returns a *DataSourceType pointing to the current value. +func (c DataSourceType) ToPtr() *DataSourceType { + return &c +} + +// IdentityType - Type of managed service identity. +type IdentityType string + +const ( + IdentityTypeSystemAssigned IdentityType = "SystemAssigned" + IdentityTypeUserAssigned IdentityType = "UserAssigned" + IdentityTypeNone IdentityType = "None" +) + +// PossibleIdentityTypeValues returns the possible values for the IdentityType const type. +func PossibleIdentityTypeValues() []IdentityType { + return []IdentityType{ + IdentityTypeSystemAssigned, + IdentityTypeUserAssigned, + IdentityTypeNone, + } +} + +// ToPtr returns a *IdentityType pointing to the current value. +func (c IdentityType) ToPtr() *IdentityType { + return &c +} + +// LinkedServiceEntityStatus - The provisioning state of the linked service. +type LinkedServiceEntityStatus string + +const ( + LinkedServiceEntityStatusDeleting LinkedServiceEntityStatus = "Deleting" + LinkedServiceEntityStatusProvisioningAccount LinkedServiceEntityStatus = "ProvisioningAccount" + LinkedServiceEntityStatusSucceeded LinkedServiceEntityStatus = "Succeeded" + LinkedServiceEntityStatusUpdating LinkedServiceEntityStatus = "Updating" +) + +// PossibleLinkedServiceEntityStatusValues returns the possible values for the LinkedServiceEntityStatus const type. +func PossibleLinkedServiceEntityStatusValues() []LinkedServiceEntityStatus { + return []LinkedServiceEntityStatus{ + LinkedServiceEntityStatusDeleting, + LinkedServiceEntityStatusProvisioningAccount, + LinkedServiceEntityStatusSucceeded, + LinkedServiceEntityStatusUpdating, + } +} + +// ToPtr returns a *LinkedServiceEntityStatus pointing to the current value. +func (c LinkedServiceEntityStatus) ToPtr() *LinkedServiceEntityStatus { + return &c +} + +// PublicNetworkAccessType - The network access type for operating on the Log Analytics Workspace. By default it is Enabled +type PublicNetworkAccessType string + +const ( + // PublicNetworkAccessTypeDisabled - Disables public connectivity to Log Analytics through public DNS. + PublicNetworkAccessTypeDisabled PublicNetworkAccessType = "Disabled" + // PublicNetworkAccessTypeEnabled - Enables connectivity to Log Analytics through public DNS. + PublicNetworkAccessTypeEnabled PublicNetworkAccessType = "Enabled" +) + +// PossiblePublicNetworkAccessTypeValues returns the possible values for the PublicNetworkAccessType const type. +func PossiblePublicNetworkAccessTypeValues() []PublicNetworkAccessType { + return []PublicNetworkAccessType{ + PublicNetworkAccessTypeDisabled, + PublicNetworkAccessTypeEnabled, + } +} + +// ToPtr returns a *PublicNetworkAccessType pointing to the current value. +func (c PublicNetworkAccessType) ToPtr() *PublicNetworkAccessType { + return &c +} + +// PurgeState - Status of the operation represented by the requested Id. +type PurgeState string + +const ( + PurgeStateCompleted PurgeState = "completed" + PurgeStatePending PurgeState = "pending" +) + +// PossiblePurgeStateValues returns the possible values for the PurgeState const type. +func PossiblePurgeStateValues() []PurgeState { + return []PurgeState{ + PurgeStateCompleted, + PurgeStatePending, + } +} + +// ToPtr returns a *PurgeState pointing to the current value. +func (c PurgeState) ToPtr() *PurgeState { + return &c +} + +// SKUNameEnum - The name of the Service Tier. +type SKUNameEnum string + +const ( + SKUNameEnumCapacityReservation SKUNameEnum = "CapacityReservation" + SKUNameEnumFree SKUNameEnum = "Free" + SKUNameEnumPerGB2018 SKUNameEnum = "PerGB2018" + SKUNameEnumPerNode SKUNameEnum = "PerNode" + SKUNameEnumPremium SKUNameEnum = "Premium" + SKUNameEnumStandalone SKUNameEnum = "Standalone" + SKUNameEnumStandard SKUNameEnum = "Standard" +) + +// PossibleSKUNameEnumValues returns the possible values for the SKUNameEnum const type. +func PossibleSKUNameEnumValues() []SKUNameEnum { + return []SKUNameEnum{ + SKUNameEnumCapacityReservation, + SKUNameEnumFree, + SKUNameEnumPerGB2018, + SKUNameEnumPerNode, + SKUNameEnumPremium, + SKUNameEnumStandalone, + SKUNameEnumStandard, + } +} + +// ToPtr returns a *SKUNameEnum pointing to the current value. +func (c SKUNameEnum) ToPtr() *SKUNameEnum { + return &c +} + +// SearchSortEnum - The sort order of the search. +type SearchSortEnum string + +const ( + SearchSortEnumAsc SearchSortEnum = "asc" + SearchSortEnumDesc SearchSortEnum = "desc" +) + +// PossibleSearchSortEnumValues returns the possible values for the SearchSortEnum const type. +func PossibleSearchSortEnumValues() []SearchSortEnum { + return []SearchSortEnum{ + SearchSortEnumAsc, + SearchSortEnumDesc, + } +} + +// ToPtr returns a *SearchSortEnum pointing to the current value. +func (c SearchSortEnum) ToPtr() *SearchSortEnum { + return &c +} + +// StorageInsightState - The state of the storage insight connection to the workspace +type StorageInsightState string + +const ( + StorageInsightStateERROR StorageInsightState = "ERROR" + StorageInsightStateOK StorageInsightState = "OK" +) + +// PossibleStorageInsightStateValues returns the possible values for the StorageInsightState const type. +func PossibleStorageInsightStateValues() []StorageInsightState { + return []StorageInsightState{ + StorageInsightStateERROR, + StorageInsightStateOK, + } +} + +// ToPtr returns a *StorageInsightState pointing to the current value. +func (c StorageInsightState) ToPtr() *StorageInsightState { + return &c +} + +// Type - The type of the destination resource +type Type string + +const ( + TypeEventHub Type = "EventHub" + TypeStorageAccount Type = "StorageAccount" +) + +// PossibleTypeValues returns the possible values for the Type const type. +func PossibleTypeValues() []Type { + return []Type{ + TypeEventHub, + TypeStorageAccount, + } +} + +// ToPtr returns a *Type pointing to the current value. +func (c Type) ToPtr() *Type { + return &c +} + +// WorkspaceEntityStatus - The provisioning state of the workspace. +type WorkspaceEntityStatus string + +const ( + WorkspaceEntityStatusCanceled WorkspaceEntityStatus = "Canceled" + WorkspaceEntityStatusCreating WorkspaceEntityStatus = "Creating" + WorkspaceEntityStatusDeleting WorkspaceEntityStatus = "Deleting" + WorkspaceEntityStatusFailed WorkspaceEntityStatus = "Failed" + WorkspaceEntityStatusProvisioningAccount WorkspaceEntityStatus = "ProvisioningAccount" + WorkspaceEntityStatusSucceeded WorkspaceEntityStatus = "Succeeded" + WorkspaceEntityStatusUpdating WorkspaceEntityStatus = "Updating" +) + +// PossibleWorkspaceEntityStatusValues returns the possible values for the WorkspaceEntityStatus const type. +func PossibleWorkspaceEntityStatusValues() []WorkspaceEntityStatus { + return []WorkspaceEntityStatus{ + WorkspaceEntityStatusCanceled, + WorkspaceEntityStatusCreating, + WorkspaceEntityStatusDeleting, + WorkspaceEntityStatusFailed, + WorkspaceEntityStatusProvisioningAccount, + WorkspaceEntityStatusSucceeded, + WorkspaceEntityStatusUpdating, + } +} + +// ToPtr returns a *WorkspaceEntityStatus pointing to the current value. +func (c WorkspaceEntityStatus) ToPtr() *WorkspaceEntityStatus { + return &c +} + +// WorkspaceSKUNameEnum - The name of the SKU. +type WorkspaceSKUNameEnum string + +const ( + WorkspaceSKUNameEnumCapacityReservation WorkspaceSKUNameEnum = "CapacityReservation" + WorkspaceSKUNameEnumFree WorkspaceSKUNameEnum = "Free" + WorkspaceSKUNameEnumLACluster WorkspaceSKUNameEnum = "LACluster" + WorkspaceSKUNameEnumPerGB2018 WorkspaceSKUNameEnum = "PerGB2018" + WorkspaceSKUNameEnumPerNode WorkspaceSKUNameEnum = "PerNode" + WorkspaceSKUNameEnumPremium WorkspaceSKUNameEnum = "Premium" + WorkspaceSKUNameEnumStandalone WorkspaceSKUNameEnum = "Standalone" + WorkspaceSKUNameEnumStandard WorkspaceSKUNameEnum = "Standard" +) + +// PossibleWorkspaceSKUNameEnumValues returns the possible values for the WorkspaceSKUNameEnum const type. +func PossibleWorkspaceSKUNameEnumValues() []WorkspaceSKUNameEnum { + return []WorkspaceSKUNameEnum{ + WorkspaceSKUNameEnumCapacityReservation, + WorkspaceSKUNameEnumFree, + WorkspaceSKUNameEnumLACluster, + WorkspaceSKUNameEnumPerGB2018, + WorkspaceSKUNameEnumPerNode, + WorkspaceSKUNameEnumPremium, + WorkspaceSKUNameEnumStandalone, + WorkspaceSKUNameEnumStandard, + } +} + +// ToPtr returns a *WorkspaceSKUNameEnum pointing to the current value. +func (c WorkspaceSKUNameEnum) ToPtr() *WorkspaceSKUNameEnum { + return &c +} diff --git a/sdk/operationalinsights/armoperationalinsights/zz_generated_dataexports_client.go b/sdk/operationalinsights/armoperationalinsights/zz_generated_dataexports_client.go new file mode 100644 index 000000000000..97ac4ec9a870 --- /dev/null +++ b/sdk/operationalinsights/armoperationalinsights/zz_generated_dataexports_client.go @@ -0,0 +1,298 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armoperationalinsights + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// DataExportsClient contains the methods for the DataExports group. +// Don't use this type directly, use NewDataExportsClient() instead. +type DataExportsClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewDataExportsClient creates a new instance of DataExportsClient with the specified values. +func NewDataExportsClient(con *armcore.Connection, subscriptionID string) *DataExportsClient { + return &DataExportsClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Create or update a data export. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DataExportsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, workspaceName string, dataExportName string, parameters DataExport, options *DataExportsCreateOrUpdateOptions) (DataExportsCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, workspaceName, dataExportName, parameters, options) + if err != nil { + return DataExportsCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return DataExportsCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return DataExportsCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *DataExportsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, dataExportName string, parameters DataExport, options *DataExportsCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataExports/{dataExportName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if dataExportName == "" { + return nil, errors.New("parameter dataExportName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataExportName}", url.PathEscape(dataExportName)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-08-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *DataExportsClient) createOrUpdateHandleResponse(resp *azcore.Response) (DataExportsCreateOrUpdateResponse, error) { + result := DataExportsCreateOrUpdateResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.DataExport); err != nil { + return DataExportsCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *DataExportsClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Deletes the specified data export in a given workspace.. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DataExportsClient) Delete(ctx context.Context, resourceGroupName string, workspaceName string, dataExportName string, options *DataExportsDeleteOptions) (DataExportsDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, workspaceName, dataExportName, options) + if err != nil { + return DataExportsDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return DataExportsDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNotFound) { + return DataExportsDeleteResponse{}, client.deleteHandleError(resp) + } + return DataExportsDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *DataExportsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, dataExportName string, options *DataExportsDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataExports/{dataExportName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if dataExportName == "" { + return nil, errors.New("parameter dataExportName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataExportName}", url.PathEscape(dataExportName)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-08-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *DataExportsClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets a data export instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DataExportsClient) Get(ctx context.Context, resourceGroupName string, workspaceName string, dataExportName string, options *DataExportsGetOptions) (DataExportsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, workspaceName, dataExportName, options) + if err != nil { + return DataExportsGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return DataExportsGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return DataExportsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *DataExportsClient) getCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, dataExportName string, options *DataExportsGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataExports/{dataExportName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if dataExportName == "" { + return nil, errors.New("parameter dataExportName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataExportName}", url.PathEscape(dataExportName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-08-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *DataExportsClient) getHandleResponse(resp *azcore.Response) (DataExportsGetResponse, error) { + result := DataExportsGetResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.DataExport); err != nil { + return DataExportsGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *DataExportsClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByWorkspace - Lists the data export instances within a workspace. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DataExportsClient) ListByWorkspace(ctx context.Context, resourceGroupName string, workspaceName string, options *DataExportsListByWorkspaceOptions) (DataExportsListByWorkspaceResponse, error) { + req, err := client.listByWorkspaceCreateRequest(ctx, resourceGroupName, workspaceName, options) + if err != nil { + return DataExportsListByWorkspaceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return DataExportsListByWorkspaceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return DataExportsListByWorkspaceResponse{}, client.listByWorkspaceHandleError(resp) + } + return client.listByWorkspaceHandleResponse(resp) +} + +// listByWorkspaceCreateRequest creates the ListByWorkspace request. +func (client *DataExportsClient) listByWorkspaceCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, options *DataExportsListByWorkspaceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataExports" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-08-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByWorkspaceHandleResponse handles the ListByWorkspace response. +func (client *DataExportsClient) listByWorkspaceHandleResponse(resp *azcore.Response) (DataExportsListByWorkspaceResponse, error) { + result := DataExportsListByWorkspaceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.DataExportListResult); err != nil { + return DataExportsListByWorkspaceResponse{}, err + } + return result, nil +} + +// listByWorkspaceHandleError handles the ListByWorkspace error response. +func (client *DataExportsClient) listByWorkspaceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/operationalinsights/armoperationalinsights/zz_generated_datasources_client.go b/sdk/operationalinsights/armoperationalinsights/zz_generated_datasources_client.go new file mode 100644 index 000000000000..2a5fba4a3626 --- /dev/null +++ b/sdk/operationalinsights/armoperationalinsights/zz_generated_datasources_client.go @@ -0,0 +1,293 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armoperationalinsights + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// DataSourcesClient contains the methods for the DataSources group. +// Don't use this type directly, use NewDataSourcesClient() instead. +type DataSourcesClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewDataSourcesClient creates a new instance of DataSourcesClient with the specified values. +func NewDataSourcesClient(con *armcore.Connection, subscriptionID string) *DataSourcesClient { + return &DataSourcesClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Create or update a data source. +// If the operation fails it returns a generic error. +func (client *DataSourcesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, workspaceName string, dataSourceName string, parameters DataSource, options *DataSourcesCreateOrUpdateOptions) (DataSourcesCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, workspaceName, dataSourceName, parameters, options) + if err != nil { + return DataSourcesCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return DataSourcesCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return DataSourcesCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *DataSourcesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, dataSourceName string, parameters DataSource, options *DataSourcesCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataSources/{dataSourceName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if dataSourceName == "" { + return nil, errors.New("parameter dataSourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataSourceName}", url.PathEscape(dataSourceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-08-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *DataSourcesClient) createOrUpdateHandleResponse(resp *azcore.Response) (DataSourcesCreateOrUpdateResponse, error) { + result := DataSourcesCreateOrUpdateResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.DataSource); err != nil { + return DataSourcesCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *DataSourcesClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// Delete - Deletes a data source instance. +// If the operation fails it returns a generic error. +func (client *DataSourcesClient) Delete(ctx context.Context, resourceGroupName string, workspaceName string, dataSourceName string, options *DataSourcesDeleteOptions) (DataSourcesDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, workspaceName, dataSourceName, options) + if err != nil { + return DataSourcesDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return DataSourcesDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return DataSourcesDeleteResponse{}, client.deleteHandleError(resp) + } + return DataSourcesDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *DataSourcesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, dataSourceName string, options *DataSourcesDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataSources/{dataSourceName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if dataSourceName == "" { + return nil, errors.New("parameter dataSourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataSourceName}", url.PathEscape(dataSourceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-08-01") + req.URL.RawQuery = reqQP.Encode() + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *DataSourcesClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// Get - Gets a datasource instance. +// If the operation fails it returns a generic error. +func (client *DataSourcesClient) Get(ctx context.Context, resourceGroupName string, workspaceName string, dataSourceName string, options *DataSourcesGetOptions) (DataSourcesGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, workspaceName, dataSourceName, options) + if err != nil { + return DataSourcesGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return DataSourcesGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return DataSourcesGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *DataSourcesClient) getCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, dataSourceName string, options *DataSourcesGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataSources/{dataSourceName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if dataSourceName == "" { + return nil, errors.New("parameter dataSourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataSourceName}", url.PathEscape(dataSourceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-08-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *DataSourcesClient) getHandleResponse(resp *azcore.Response) (DataSourcesGetResponse, error) { + result := DataSourcesGetResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.DataSource); err != nil { + return DataSourcesGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *DataSourcesClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// ListByWorkspace - Gets the first page of data source instances in a workspace with the link to the next page. +// If the operation fails it returns a generic error. +func (client *DataSourcesClient) ListByWorkspace(resourceGroupName string, workspaceName string, filter string, options *DataSourcesListByWorkspaceOptions) DataSourcesListByWorkspacePager { + return &dataSourcesListByWorkspacePager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByWorkspaceCreateRequest(ctx, resourceGroupName, workspaceName, filter, options) + }, + advancer: func(ctx context.Context, resp DataSourcesListByWorkspaceResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.DataSourceListResult.NextLink) + }, + } +} + +// listByWorkspaceCreateRequest creates the ListByWorkspace request. +func (client *DataSourcesClient) listByWorkspaceCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, filter string, options *DataSourcesListByWorkspaceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/dataSources" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("$filter", filter) + if options != nil && options.Skiptoken != nil { + reqQP.Set("$skiptoken", *options.Skiptoken) + } + reqQP.Set("api-version", "2020-08-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByWorkspaceHandleResponse handles the ListByWorkspace response. +func (client *DataSourcesClient) listByWorkspaceHandleResponse(resp *azcore.Response) (DataSourcesListByWorkspaceResponse, error) { + result := DataSourcesListByWorkspaceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.DataSourceListResult); err != nil { + return DataSourcesListByWorkspaceResponse{}, err + } + return result, nil +} + +// listByWorkspaceHandleError handles the ListByWorkspace error response. +func (client *DataSourcesClient) listByWorkspaceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} diff --git a/sdk/operationalinsights/armoperationalinsights/zz_generated_deletedworkspaces_client.go b/sdk/operationalinsights/armoperationalinsights/zz_generated_deletedworkspaces_client.go new file mode 100644 index 000000000000..09dd95d206c0 --- /dev/null +++ b/sdk/operationalinsights/armoperationalinsights/zz_generated_deletedworkspaces_client.go @@ -0,0 +1,151 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armoperationalinsights + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// DeletedWorkspacesClient contains the methods for the DeletedWorkspaces group. +// Don't use this type directly, use NewDeletedWorkspacesClient() instead. +type DeletedWorkspacesClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewDeletedWorkspacesClient creates a new instance of DeletedWorkspacesClient with the specified values. +func NewDeletedWorkspacesClient(con *armcore.Connection, subscriptionID string) *DeletedWorkspacesClient { + return &DeletedWorkspacesClient{con: con, subscriptionID: subscriptionID} +} + +// List - Gets recently deleted workspaces in a subscription, available for recovery. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DeletedWorkspacesClient) List(ctx context.Context, options *DeletedWorkspacesListOptions) (DeletedWorkspacesListResponse, error) { + req, err := client.listCreateRequest(ctx, options) + if err != nil { + return DeletedWorkspacesListResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return DeletedWorkspacesListResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return DeletedWorkspacesListResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *DeletedWorkspacesClient) listCreateRequest(ctx context.Context, options *DeletedWorkspacesListOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.OperationalInsights/deletedWorkspaces" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-10-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *DeletedWorkspacesClient) listHandleResponse(resp *azcore.Response) (DeletedWorkspacesListResponse, error) { + result := DeletedWorkspacesListResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.WorkspaceListResult); err != nil { + return DeletedWorkspacesListResponse{}, err + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *DeletedWorkspacesClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByResourceGroup - Gets recently deleted workspaces in a resource group, available for recovery. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DeletedWorkspacesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, options *DeletedWorkspacesListByResourceGroupOptions) (DeletedWorkspacesListByResourceGroupResponse, error) { + req, err := client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + if err != nil { + return DeletedWorkspacesListByResourceGroupResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return DeletedWorkspacesListByResourceGroupResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return DeletedWorkspacesListByResourceGroupResponse{}, client.listByResourceGroupHandleError(resp) + } + return client.listByResourceGroupHandleResponse(resp) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *DeletedWorkspacesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *DeletedWorkspacesListByResourceGroupOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/deletedWorkspaces" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-10-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *DeletedWorkspacesClient) listByResourceGroupHandleResponse(resp *azcore.Response) (DeletedWorkspacesListByResourceGroupResponse, error) { + result := DeletedWorkspacesListByResourceGroupResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.WorkspaceListResult); err != nil { + return DeletedWorkspacesListByResourceGroupResponse{}, err + } + return result, nil +} + +// listByResourceGroupHandleError handles the ListByResourceGroup error response. +func (client *DeletedWorkspacesClient) listByResourceGroupHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/operationalinsights/armoperationalinsights/zz_generated_gateways_client.go b/sdk/operationalinsights/armoperationalinsights/zz_generated_gateways_client.go new file mode 100644 index 000000000000..2146ac003017 --- /dev/null +++ b/sdk/operationalinsights/armoperationalinsights/zz_generated_gateways_client.go @@ -0,0 +1,89 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armoperationalinsights + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// GatewaysClient contains the methods for the Gateways group. +// Don't use this type directly, use NewGatewaysClient() instead. +type GatewaysClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewGatewaysClient creates a new instance of GatewaysClient with the specified values. +func NewGatewaysClient(con *armcore.Connection, subscriptionID string) *GatewaysClient { + return &GatewaysClient{con: con, subscriptionID: subscriptionID} +} + +// Delete - Delete a Log Analytics gateway. +// If the operation fails it returns a generic error. +func (client *GatewaysClient) Delete(ctx context.Context, resourceGroupName string, workspaceName string, gatewayID string, options *GatewaysDeleteOptions) (GatewaysDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, workspaceName, gatewayID, options) + if err != nil { + return GatewaysDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return GatewaysDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return GatewaysDeleteResponse{}, client.deleteHandleError(resp) + } + return GatewaysDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *GatewaysClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, gatewayID string, options *GatewaysDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/gateways/{gatewayId}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if gatewayID == "" { + return nil, errors.New("parameter gatewayID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{gatewayId}", url.PathEscape(gatewayID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-08-01") + req.URL.RawQuery = reqQP.Encode() + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *GatewaysClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} diff --git a/sdk/operationalinsights/armoperationalinsights/zz_generated_intelligencepacks_client.go b/sdk/operationalinsights/armoperationalinsights/zz_generated_intelligencepacks_client.go new file mode 100644 index 000000000000..3c4e37822935 --- /dev/null +++ b/sdk/operationalinsights/armoperationalinsights/zz_generated_intelligencepacks_client.go @@ -0,0 +1,213 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armoperationalinsights + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// IntelligencePacksClient contains the methods for the IntelligencePacks group. +// Don't use this type directly, use NewIntelligencePacksClient() instead. +type IntelligencePacksClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewIntelligencePacksClient creates a new instance of IntelligencePacksClient with the specified values. +func NewIntelligencePacksClient(con *armcore.Connection, subscriptionID string) *IntelligencePacksClient { + return &IntelligencePacksClient{con: con, subscriptionID: subscriptionID} +} + +// Disable - Disables an intelligence pack for a given workspace. +// If the operation fails it returns a generic error. +func (client *IntelligencePacksClient) Disable(ctx context.Context, resourceGroupName string, workspaceName string, intelligencePackName string, options *IntelligencePacksDisableOptions) (IntelligencePacksDisableResponse, error) { + req, err := client.disableCreateRequest(ctx, resourceGroupName, workspaceName, intelligencePackName, options) + if err != nil { + return IntelligencePacksDisableResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return IntelligencePacksDisableResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return IntelligencePacksDisableResponse{}, client.disableHandleError(resp) + } + return IntelligencePacksDisableResponse{RawResponse: resp.Response}, nil +} + +// disableCreateRequest creates the Disable request. +func (client *IntelligencePacksClient) disableCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, intelligencePackName string, options *IntelligencePacksDisableOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/intelligencePacks/{intelligencePackName}/Disable" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if intelligencePackName == "" { + return nil, errors.New("parameter intelligencePackName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{intelligencePackName}", url.PathEscape(intelligencePackName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-08-01") + req.URL.RawQuery = reqQP.Encode() + return req, nil +} + +// disableHandleError handles the Disable error response. +func (client *IntelligencePacksClient) disableHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// Enable - Enables an intelligence pack for a given workspace. +// If the operation fails it returns a generic error. +func (client *IntelligencePacksClient) Enable(ctx context.Context, resourceGroupName string, workspaceName string, intelligencePackName string, options *IntelligencePacksEnableOptions) (IntelligencePacksEnableResponse, error) { + req, err := client.enableCreateRequest(ctx, resourceGroupName, workspaceName, intelligencePackName, options) + if err != nil { + return IntelligencePacksEnableResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return IntelligencePacksEnableResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return IntelligencePacksEnableResponse{}, client.enableHandleError(resp) + } + return IntelligencePacksEnableResponse{RawResponse: resp.Response}, nil +} + +// enableCreateRequest creates the Enable request. +func (client *IntelligencePacksClient) enableCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, intelligencePackName string, options *IntelligencePacksEnableOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/intelligencePacks/{intelligencePackName}/Enable" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if intelligencePackName == "" { + return nil, errors.New("parameter intelligencePackName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{intelligencePackName}", url.PathEscape(intelligencePackName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-08-01") + req.URL.RawQuery = reqQP.Encode() + return req, nil +} + +// enableHandleError handles the Enable error response. +func (client *IntelligencePacksClient) enableHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// List - Lists all the intelligence packs possible and whether they are enabled or disabled for a given workspace. +// If the operation fails it returns a generic error. +func (client *IntelligencePacksClient) List(ctx context.Context, resourceGroupName string, workspaceName string, options *IntelligencePacksListOptions) (IntelligencePacksListResponse, error) { + req, err := client.listCreateRequest(ctx, resourceGroupName, workspaceName, options) + if err != nil { + return IntelligencePacksListResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return IntelligencePacksListResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return IntelligencePacksListResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *IntelligencePacksClient) listCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, options *IntelligencePacksListOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/intelligencePacks" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-08-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *IntelligencePacksClient) listHandleResponse(resp *azcore.Response) (IntelligencePacksListResponse, error) { + result := IntelligencePacksListResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.IntelligencePackArray); err != nil { + return IntelligencePacksListResponse{}, err + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *IntelligencePacksClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} diff --git a/sdk/operationalinsights/armoperationalinsights/zz_generated_linkedservices_client.go b/sdk/operationalinsights/armoperationalinsights/zz_generated_linkedservices_client.go new file mode 100644 index 000000000000..6fcd71d5c33e --- /dev/null +++ b/sdk/operationalinsights/armoperationalinsights/zz_generated_linkedservices_client.go @@ -0,0 +1,381 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armoperationalinsights + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" + "time" +) + +// LinkedServicesClient contains the methods for the LinkedServices group. +// Don't use this type directly, use NewLinkedServicesClient() instead. +type LinkedServicesClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewLinkedServicesClient creates a new instance of LinkedServicesClient with the specified values. +func NewLinkedServicesClient(con *armcore.Connection, subscriptionID string) *LinkedServicesClient { + return &LinkedServicesClient{con: con, subscriptionID: subscriptionID} +} + +// BeginCreateOrUpdate - Create or update a linked service. +// If the operation fails it returns a generic error. +func (client *LinkedServicesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, workspaceName string, linkedServiceName string, parameters LinkedService, options *LinkedServicesBeginCreateOrUpdateOptions) (LinkedServicesCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, workspaceName, linkedServiceName, parameters, options) + if err != nil { + return LinkedServicesCreateOrUpdatePollerResponse{}, err + } + result := LinkedServicesCreateOrUpdatePollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("LinkedServicesClient.CreateOrUpdate", "", resp, client.con.Pipeline(), client.createOrUpdateHandleError) + if err != nil { + return LinkedServicesCreateOrUpdatePollerResponse{}, err + } + poller := &linkedServicesCreateOrUpdatePoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (LinkedServicesCreateOrUpdateResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeCreateOrUpdate creates a new LinkedServicesCreateOrUpdatePoller from the specified resume token. +// token - The value must come from a previous call to LinkedServicesCreateOrUpdatePoller.ResumeToken(). +func (client *LinkedServicesClient) ResumeCreateOrUpdate(ctx context.Context, token string) (LinkedServicesCreateOrUpdatePollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("LinkedServicesClient.CreateOrUpdate", token, client.con.Pipeline(), client.createOrUpdateHandleError) + if err != nil { + return LinkedServicesCreateOrUpdatePollerResponse{}, err + } + poller := &linkedServicesCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return LinkedServicesCreateOrUpdatePollerResponse{}, err + } + result := LinkedServicesCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (LinkedServicesCreateOrUpdateResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// CreateOrUpdate - Create or update a linked service. +// If the operation fails it returns a generic error. +func (client *LinkedServicesClient) createOrUpdate(ctx context.Context, resourceGroupName string, workspaceName string, linkedServiceName string, parameters LinkedService, options *LinkedServicesBeginCreateOrUpdateOptions) (*azcore.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, workspaceName, linkedServiceName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted) { + return nil, client.createOrUpdateHandleError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *LinkedServicesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, linkedServiceName string, parameters LinkedService, options *LinkedServicesBeginCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedServices/{linkedServiceName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if linkedServiceName == "" { + return nil, errors.New("parameter linkedServiceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{linkedServiceName}", url.PathEscape(linkedServiceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-08-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *LinkedServicesClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// BeginDelete - Deletes a linked service instance. +// If the operation fails it returns a generic error. +func (client *LinkedServicesClient) BeginDelete(ctx context.Context, resourceGroupName string, workspaceName string, linkedServiceName string, options *LinkedServicesBeginDeleteOptions) (LinkedServicesDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, workspaceName, linkedServiceName, options) + if err != nil { + return LinkedServicesDeletePollerResponse{}, err + } + result := LinkedServicesDeletePollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("LinkedServicesClient.Delete", "", resp, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return LinkedServicesDeletePollerResponse{}, err + } + poller := &linkedServicesDeletePoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (LinkedServicesDeleteResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeDelete creates a new LinkedServicesDeletePoller from the specified resume token. +// token - The value must come from a previous call to LinkedServicesDeletePoller.ResumeToken(). +func (client *LinkedServicesClient) ResumeDelete(ctx context.Context, token string) (LinkedServicesDeletePollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("LinkedServicesClient.Delete", token, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return LinkedServicesDeletePollerResponse{}, err + } + poller := &linkedServicesDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return LinkedServicesDeletePollerResponse{}, err + } + result := LinkedServicesDeletePollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (LinkedServicesDeleteResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Delete - Deletes a linked service instance. +// If the operation fails it returns a generic error. +func (client *LinkedServicesClient) deleteOperation(ctx context.Context, resourceGroupName string, workspaceName string, linkedServiceName string, options *LinkedServicesBeginDeleteOptions) (*azcore.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, workspaceName, linkedServiceName, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *LinkedServicesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, linkedServiceName string, options *LinkedServicesBeginDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedServices/{linkedServiceName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if linkedServiceName == "" { + return nil, errors.New("parameter linkedServiceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{linkedServiceName}", url.PathEscape(linkedServiceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-08-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *LinkedServicesClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// Get - Gets a linked service instance. +// If the operation fails it returns a generic error. +func (client *LinkedServicesClient) Get(ctx context.Context, resourceGroupName string, workspaceName string, linkedServiceName string, options *LinkedServicesGetOptions) (LinkedServicesGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, workspaceName, linkedServiceName, options) + if err != nil { + return LinkedServicesGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return LinkedServicesGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return LinkedServicesGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *LinkedServicesClient) getCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, linkedServiceName string, options *LinkedServicesGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedServices/{linkedServiceName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if linkedServiceName == "" { + return nil, errors.New("parameter linkedServiceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{linkedServiceName}", url.PathEscape(linkedServiceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-08-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *LinkedServicesClient) getHandleResponse(resp *azcore.Response) (LinkedServicesGetResponse, error) { + result := LinkedServicesGetResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.LinkedService); err != nil { + return LinkedServicesGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *LinkedServicesClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// ListByWorkspace - Gets the linked services instances in a workspace. +// If the operation fails it returns a generic error. +func (client *LinkedServicesClient) ListByWorkspace(ctx context.Context, resourceGroupName string, workspaceName string, options *LinkedServicesListByWorkspaceOptions) (LinkedServicesListByWorkspaceResponse, error) { + req, err := client.listByWorkspaceCreateRequest(ctx, resourceGroupName, workspaceName, options) + if err != nil { + return LinkedServicesListByWorkspaceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return LinkedServicesListByWorkspaceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return LinkedServicesListByWorkspaceResponse{}, client.listByWorkspaceHandleError(resp) + } + return client.listByWorkspaceHandleResponse(resp) +} + +// listByWorkspaceCreateRequest creates the ListByWorkspace request. +func (client *LinkedServicesClient) listByWorkspaceCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, options *LinkedServicesListByWorkspaceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedServices" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-08-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByWorkspaceHandleResponse handles the ListByWorkspace response. +func (client *LinkedServicesClient) listByWorkspaceHandleResponse(resp *azcore.Response) (LinkedServicesListByWorkspaceResponse, error) { + result := LinkedServicesListByWorkspaceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.LinkedServiceListResult); err != nil { + return LinkedServicesListByWorkspaceResponse{}, err + } + return result, nil +} + +// listByWorkspaceHandleError handles the ListByWorkspace error response. +func (client *LinkedServicesClient) listByWorkspaceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} diff --git a/sdk/operationalinsights/armoperationalinsights/zz_generated_linkedstorageaccounts_client.go b/sdk/operationalinsights/armoperationalinsights/zz_generated_linkedstorageaccounts_client.go new file mode 100644 index 000000000000..5be8ae6ab3e8 --- /dev/null +++ b/sdk/operationalinsights/armoperationalinsights/zz_generated_linkedstorageaccounts_client.go @@ -0,0 +1,292 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armoperationalinsights + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// LinkedStorageAccountsClient contains the methods for the LinkedStorageAccounts group. +// Don't use this type directly, use NewLinkedStorageAccountsClient() instead. +type LinkedStorageAccountsClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewLinkedStorageAccountsClient creates a new instance of LinkedStorageAccountsClient with the specified values. +func NewLinkedStorageAccountsClient(con *armcore.Connection, subscriptionID string) *LinkedStorageAccountsClient { + return &LinkedStorageAccountsClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Create or Update a link relation between current workspace and a group of storage accounts of a specific data source type. +// If the operation fails it returns a generic error. +func (client *LinkedStorageAccountsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, workspaceName string, dataSourceType DataSourceType, parameters LinkedStorageAccountsResource, options *LinkedStorageAccountsCreateOrUpdateOptions) (LinkedStorageAccountsCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, workspaceName, dataSourceType, parameters, options) + if err != nil { + return LinkedStorageAccountsCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return LinkedStorageAccountsCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return LinkedStorageAccountsCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *LinkedStorageAccountsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, dataSourceType DataSourceType, parameters LinkedStorageAccountsResource, options *LinkedStorageAccountsCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedStorageAccounts/{dataSourceType}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if dataSourceType == "" { + return nil, errors.New("parameter dataSourceType cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataSourceType}", url.PathEscape(string(dataSourceType))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-08-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *LinkedStorageAccountsClient) createOrUpdateHandleResponse(resp *azcore.Response) (LinkedStorageAccountsCreateOrUpdateResponse, error) { + result := LinkedStorageAccountsCreateOrUpdateResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.LinkedStorageAccountsResource); err != nil { + return LinkedStorageAccountsCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *LinkedStorageAccountsClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// Delete - Deletes all linked storage accounts of a specific data source type associated with the specified workspace. +// If the operation fails it returns a generic error. +func (client *LinkedStorageAccountsClient) Delete(ctx context.Context, resourceGroupName string, workspaceName string, dataSourceType DataSourceType, options *LinkedStorageAccountsDeleteOptions) (LinkedStorageAccountsDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, workspaceName, dataSourceType, options) + if err != nil { + return LinkedStorageAccountsDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return LinkedStorageAccountsDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return LinkedStorageAccountsDeleteResponse{}, client.deleteHandleError(resp) + } + return LinkedStorageAccountsDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *LinkedStorageAccountsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, dataSourceType DataSourceType, options *LinkedStorageAccountsDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedStorageAccounts/{dataSourceType}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if dataSourceType == "" { + return nil, errors.New("parameter dataSourceType cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataSourceType}", url.PathEscape(string(dataSourceType))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-08-01") + req.URL.RawQuery = reqQP.Encode() + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *LinkedStorageAccountsClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// Get - Gets all linked storage account of a specific data source type associated with the specified workspace. +// If the operation fails it returns a generic error. +func (client *LinkedStorageAccountsClient) Get(ctx context.Context, resourceGroupName string, workspaceName string, dataSourceType DataSourceType, options *LinkedStorageAccountsGetOptions) (LinkedStorageAccountsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, workspaceName, dataSourceType, options) + if err != nil { + return LinkedStorageAccountsGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return LinkedStorageAccountsGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return LinkedStorageAccountsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *LinkedStorageAccountsClient) getCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, dataSourceType DataSourceType, options *LinkedStorageAccountsGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedStorageAccounts/{dataSourceType}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if dataSourceType == "" { + return nil, errors.New("parameter dataSourceType cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataSourceType}", url.PathEscape(string(dataSourceType))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-08-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *LinkedStorageAccountsClient) getHandleResponse(resp *azcore.Response) (LinkedStorageAccountsGetResponse, error) { + result := LinkedStorageAccountsGetResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.LinkedStorageAccountsResource); err != nil { + return LinkedStorageAccountsGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *LinkedStorageAccountsClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// ListByWorkspace - Gets all linked storage accounts associated with the specified workspace, storage accounts will be sorted by their data source type. +// If the operation fails it returns a generic error. +func (client *LinkedStorageAccountsClient) ListByWorkspace(ctx context.Context, resourceGroupName string, workspaceName string, options *LinkedStorageAccountsListByWorkspaceOptions) (LinkedStorageAccountsListByWorkspaceResponse, error) { + req, err := client.listByWorkspaceCreateRequest(ctx, resourceGroupName, workspaceName, options) + if err != nil { + return LinkedStorageAccountsListByWorkspaceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return LinkedStorageAccountsListByWorkspaceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return LinkedStorageAccountsListByWorkspaceResponse{}, client.listByWorkspaceHandleError(resp) + } + return client.listByWorkspaceHandleResponse(resp) +} + +// listByWorkspaceCreateRequest creates the ListByWorkspace request. +func (client *LinkedStorageAccountsClient) listByWorkspaceCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, options *LinkedStorageAccountsListByWorkspaceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/linkedStorageAccounts" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-08-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByWorkspaceHandleResponse handles the ListByWorkspace response. +func (client *LinkedStorageAccountsClient) listByWorkspaceHandleResponse(resp *azcore.Response) (LinkedStorageAccountsListByWorkspaceResponse, error) { + result := LinkedStorageAccountsListByWorkspaceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.LinkedStorageAccountsListResult); err != nil { + return LinkedStorageAccountsListByWorkspaceResponse{}, err + } + return result, nil +} + +// listByWorkspaceHandleError handles the ListByWorkspace error response. +func (client *LinkedStorageAccountsClient) listByWorkspaceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} diff --git a/sdk/operationalinsights/armoperationalinsights/zz_generated_managementgroups_client.go b/sdk/operationalinsights/armoperationalinsights/zz_generated_managementgroups_client.go new file mode 100644 index 000000000000..704914c01a83 --- /dev/null +++ b/sdk/operationalinsights/armoperationalinsights/zz_generated_managementgroups_client.go @@ -0,0 +1,95 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armoperationalinsights + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// ManagementGroupsClient contains the methods for the ManagementGroups group. +// Don't use this type directly, use NewManagementGroupsClient() instead. +type ManagementGroupsClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewManagementGroupsClient creates a new instance of ManagementGroupsClient with the specified values. +func NewManagementGroupsClient(con *armcore.Connection, subscriptionID string) *ManagementGroupsClient { + return &ManagementGroupsClient{con: con, subscriptionID: subscriptionID} +} + +// List - Gets a list of management groups connected to a workspace. +// If the operation fails it returns a generic error. +func (client *ManagementGroupsClient) List(ctx context.Context, resourceGroupName string, workspaceName string, options *ManagementGroupsListOptions) (ManagementGroupsListResponse, error) { + req, err := client.listCreateRequest(ctx, resourceGroupName, workspaceName, options) + if err != nil { + return ManagementGroupsListResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ManagementGroupsListResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return ManagementGroupsListResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *ManagementGroupsClient) listCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, options *ManagementGroupsListOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/managementGroups" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-08-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ManagementGroupsClient) listHandleResponse(resp *azcore.Response) (ManagementGroupsListResponse, error) { + result := ManagementGroupsListResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.WorkspaceListManagementGroupsResult); err != nil { + return ManagementGroupsListResponse{}, err + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *ManagementGroupsClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} diff --git a/sdk/operationalinsights/armoperationalinsights/zz_generated_models.go b/sdk/operationalinsights/armoperationalinsights/zz_generated_models.go new file mode 100644 index 000000000000..ff99673b5594 --- /dev/null +++ b/sdk/operationalinsights/armoperationalinsights/zz_generated_models.go @@ -0,0 +1,1852 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armoperationalinsights + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "time" +) + +// AssociatedWorkspace - The list of Log Analytics workspaces associated with the cluster. +type AssociatedWorkspace struct { + // READ-ONLY; The time of workspace association. + AssociateDate *string `json:"associateDate,omitempty" azure:"ro"` + + // READ-ONLY; The ResourceId id the assigned workspace. + ResourceID *string `json:"resourceId,omitempty" azure:"ro"` + + // READ-ONLY; The id of the assigned workspace. + WorkspaceID *string `json:"workspaceId,omitempty" azure:"ro"` + + // READ-ONLY; The name id the assigned workspace. + WorkspaceName *string `json:"workspaceName,omitempty" azure:"ro"` +} + +// AvailableServiceTier - Service Tier details. +type AvailableServiceTier struct { + // READ-ONLY; The capacity reservation level in GB per day. Returned for the Capacity Reservation Service Tier. + CapacityReservationLevel *int64 `json:"capacityReservationLevel,omitempty" azure:"ro"` + + // READ-ONLY; The default retention for the Service Tier, in days. + DefaultRetention *int64 `json:"defaultRetention,omitempty" azure:"ro"` + + // READ-ONLY; True if the Service Tier is enabled for the workspace. + Enabled *bool `json:"enabled,omitempty" azure:"ro"` + + // READ-ONLY; Time when the sku was last updated for the workspace. Returned for the Capacity Reservation Service Tier. + LastSKUUpdate *string `json:"lastSkuUpdate,omitempty" azure:"ro"` + + // READ-ONLY; The maximum retention for the Service Tier, in days. + MaximumRetention *int64 `json:"maximumRetention,omitempty" azure:"ro"` + + // READ-ONLY; The minimum retention for the Service Tier, in days. + MinimumRetention *int64 `json:"minimumRetention,omitempty" azure:"ro"` + + // READ-ONLY; The name of the Service Tier. + ServiceTier *SKUNameEnum `json:"serviceTier,omitempty" azure:"ro"` +} + +// AvailableServiceTiersListByWorkspaceOptions contains the optional parameters for the AvailableServiceTiers.ListByWorkspace method. +type AvailableServiceTiersListByWorkspaceOptions struct { + // placeholder for future optional parameters +} + +// AzureEntityResource - The resource model definition for an Azure Resource Manager resource with an etag. +type AzureEntityResource struct { + Resource + // READ-ONLY; Resource Etag. + Etag *string `json:"etag,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type AzureEntityResource. +func (a AzureEntityResource) MarshalJSON() ([]byte, error) { + objectMap := a.marshalInternal() + return json.Marshal(objectMap) +} + +func (a AzureEntityResource) marshalInternal() map[string]interface{} { + objectMap := a.Resource.marshalInternal() + populate(objectMap, "etag", a.Etag) + return objectMap +} + +// CapacityReservationProperties - The Capacity Reservation properties. +type CapacityReservationProperties struct { + // READ-ONLY; The last time Sku was updated. + LastSKUUpdate *string `json:"lastSkuUpdate,omitempty" azure:"ro"` + + // READ-ONLY; Minimum CapacityReservation value in GB. + MinCapacity *int64 `json:"minCapacity,omitempty" azure:"ro"` +} + +// Cluster - The top level Log Analytics cluster resource container. +type Cluster struct { + TrackedResource + // The identity of the resource. + Identity *Identity `json:"identity,omitempty"` + + // Log Analytics cluster properties. + Properties *ClusterProperties `json:"properties,omitempty"` + + // The sku properties. + SKU *ClusterSKU `json:"sku,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type Cluster. +func (c Cluster) MarshalJSON() ([]byte, error) { + objectMap := c.TrackedResource.marshalInternal() + populate(objectMap, "identity", c.Identity) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "sku", c.SKU) + return json.Marshal(objectMap) +} + +// ClusterListResult - The list clusters operation response. +type ClusterListResult struct { + // The link used to get the next page of recommendations. + NextLink *string `json:"nextLink,omitempty"` + + // A list of Log Analytics clusters. + Value []*Cluster `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ClusterListResult. +func (c ClusterListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// ClusterPatch - The top level Log Analytics cluster resource container. +type ClusterPatch struct { + // The identity of the resource. + Identity *Identity `json:"identity,omitempty"` + + // Log Analytics cluster properties. + Properties *ClusterPatchProperties `json:"properties,omitempty"` + + // The sku properties. + SKU *ClusterSKU `json:"sku,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ClusterPatch. +func (c ClusterPatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "identity", c.Identity) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "sku", c.SKU) + populate(objectMap, "tags", c.Tags) + return json.Marshal(objectMap) +} + +// ClusterPatchProperties - Log Analytics cluster patch properties. +type ClusterPatchProperties struct { + // The cluster's billing type. + BillingType *BillingType `json:"billingType,omitempty"` + + // The associated key properties. + KeyVaultProperties *KeyVaultProperties `json:"keyVaultProperties,omitempty"` +} + +// ClusterProperties - Cluster properties. +type ClusterProperties struct { + // The list of Log Analytics workspaces associated with the cluster + AssociatedWorkspaces []*AssociatedWorkspace `json:"associatedWorkspaces,omitempty"` + + // The cluster's billing type. + BillingType *BillingType `json:"billingType,omitempty"` + + // Additional properties for capacity reservation + CapacityReservationProperties *CapacityReservationProperties `json:"capacityReservationProperties,omitempty"` + + // Sets whether the cluster will support availability zones. This can be set as true only in regions where Azure Data Explorer support Availability Zones. + // This Property can not be modified after cluster + // creation. Default value is 'true' if region supports Availability Zones. + IsAvailabilityZonesEnabled *bool `json:"isAvailabilityZonesEnabled,omitempty"` + + // Configures whether cluster will use double encryption. This Property can not be modified after cluster creation. Default value is 'true' + IsDoubleEncryptionEnabled *bool `json:"isDoubleEncryptionEnabled,omitempty"` + + // The associated key properties. + KeyVaultProperties *KeyVaultProperties `json:"keyVaultProperties,omitempty"` + + // READ-ONLY; The ID associated with the cluster. + ClusterID *string `json:"clusterId,omitempty" azure:"ro"` + + // READ-ONLY; The cluster creation time + CreatedDate *string `json:"createdDate,omitempty" azure:"ro"` + + // READ-ONLY; The last time the cluster was updated. + LastModifiedDate *string `json:"lastModifiedDate,omitempty" azure:"ro"` + + // READ-ONLY; The provisioning state of the cluster. + ProvisioningState *ClusterEntityStatus `json:"provisioningState,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ClusterProperties. +func (c ClusterProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "associatedWorkspaces", c.AssociatedWorkspaces) + populate(objectMap, "billingType", c.BillingType) + populate(objectMap, "capacityReservationProperties", c.CapacityReservationProperties) + populate(objectMap, "clusterId", c.ClusterID) + populate(objectMap, "createdDate", c.CreatedDate) + populate(objectMap, "isAvailabilityZonesEnabled", c.IsAvailabilityZonesEnabled) + populate(objectMap, "isDoubleEncryptionEnabled", c.IsDoubleEncryptionEnabled) + populate(objectMap, "keyVaultProperties", c.KeyVaultProperties) + populate(objectMap, "lastModifiedDate", c.LastModifiedDate) + populate(objectMap, "provisioningState", c.ProvisioningState) + return json.Marshal(objectMap) +} + +// ClusterSKU - The cluster sku definition. +type ClusterSKU struct { + // The capacity value + Capacity *int64 `json:"capacity,omitempty"` + + // The name of the SKU. + Name *ClusterSKUNameEnum `json:"name,omitempty"` +} + +// ClustersBeginCreateOrUpdateOptions contains the optional parameters for the Clusters.BeginCreateOrUpdate method. +type ClustersBeginCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// ClustersBeginDeleteOptions contains the optional parameters for the Clusters.BeginDelete method. +type ClustersBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// ClustersGetOptions contains the optional parameters for the Clusters.Get method. +type ClustersGetOptions struct { + // placeholder for future optional parameters +} + +// ClustersListByResourceGroupOptions contains the optional parameters for the Clusters.ListByResourceGroup method. +type ClustersListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// ClustersListOptions contains the optional parameters for the Clusters.List method. +type ClustersListOptions struct { + // placeholder for future optional parameters +} + +// ClustersUpdateOptions contains the optional parameters for the Clusters.Update method. +type ClustersUpdateOptions struct { + // placeholder for future optional parameters +} + +// CoreSummary - The core summary of a search. +type CoreSummary struct { + // REQUIRED; The number of documents of a core summary. + NumberOfDocuments *int64 `json:"numberOfDocuments,omitempty"` + + // The status of a core summary. + Status *string `json:"status,omitempty"` +} + +// DataExport - The top level data export resource container. +type DataExport struct { + ProxyResource + // data export properties. + Properties *DataExportProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type DataExport. +func (d DataExport) MarshalJSON() ([]byte, error) { + objectMap := d.ProxyResource.marshalInternal() + populate(objectMap, "properties", d.Properties) + return json.Marshal(objectMap) +} + +// DataExportListResult - Result of the request to list data exports. +type DataExportListResult struct { + // List of data export instances within a workspace.. + Value []*DataExport `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type DataExportListResult. +func (d DataExportListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// DataExportProperties - Data Export properties. +type DataExportProperties struct { + // REQUIRED; An array of tables to export, for example: [“Heartbeat, SecurityEvent”]. + TableNames []*string `json:"tableNames,omitempty"` + + // The latest data export rule modification time. + CreatedDate *string `json:"createdDate,omitempty"` + + // The data export rule ID. + DataExportID *string `json:"dataExportId,omitempty"` + + // destination properties. + Destination *Destination `json:"destination,omitempty"` + + // Active when enabled. + Enable *bool `json:"enable,omitempty"` + + // Date and time when the export was last modified. + LastModifiedDate *string `json:"lastModifiedDate,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type DataExportProperties. +func (d DataExportProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "createdDate", d.CreatedDate) + populate(objectMap, "dataExportId", d.DataExportID) + populate(objectMap, "destination", d.Destination) + populate(objectMap, "enable", d.Enable) + populate(objectMap, "lastModifiedDate", d.LastModifiedDate) + populate(objectMap, "tableNames", d.TableNames) + return json.Marshal(objectMap) +} + +// DataExportsCreateOrUpdateOptions contains the optional parameters for the DataExports.CreateOrUpdate method. +type DataExportsCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// DataExportsDeleteOptions contains the optional parameters for the DataExports.Delete method. +type DataExportsDeleteOptions struct { + // placeholder for future optional parameters +} + +// DataExportsGetOptions contains the optional parameters for the DataExports.Get method. +type DataExportsGetOptions struct { + // placeholder for future optional parameters +} + +// DataExportsListByWorkspaceOptions contains the optional parameters for the DataExports.ListByWorkspace method. +type DataExportsListByWorkspaceOptions struct { + // placeholder for future optional parameters +} + +// DataSource - Datasources under OMS Workspace. +type DataSource struct { + ProxyResource + // REQUIRED; The kind of the DataSource. + Kind *DataSourceKind `json:"kind,omitempty"` + + // REQUIRED; The data source properties in raw json format, each kind of data source have it's own schema. + Properties map[string]interface{} `json:"properties,omitempty"` + + // The ETag of the data source. + Etag *string `json:"etag,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type DataSource. +func (d DataSource) MarshalJSON() ([]byte, error) { + objectMap := d.ProxyResource.marshalInternal() + populate(objectMap, "etag", d.Etag) + populate(objectMap, "kind", d.Kind) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "tags", d.Tags) + return json.Marshal(objectMap) +} + +// DataSourceFilter - DataSource filter. Right now, only filter by kind is supported. +type DataSourceFilter struct { + // The kind of the DataSource. + Kind *DataSourceKind `json:"kind,omitempty"` +} + +// DataSourceListResult - The list data source by workspace operation response. +type DataSourceListResult struct { + // The link (url) to the next page of datasources. + NextLink *string `json:"nextLink,omitempty"` + + // A list of datasources. + Value []*DataSource `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type DataSourceListResult. +func (d DataSourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", d.NextLink) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// DataSourcesCreateOrUpdateOptions contains the optional parameters for the DataSources.CreateOrUpdate method. +type DataSourcesCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// DataSourcesDeleteOptions contains the optional parameters for the DataSources.Delete method. +type DataSourcesDeleteOptions struct { + // placeholder for future optional parameters +} + +// DataSourcesGetOptions contains the optional parameters for the DataSources.Get method. +type DataSourcesGetOptions struct { + // placeholder for future optional parameters +} + +// DataSourcesListByWorkspaceOptions contains the optional parameters for the DataSources.ListByWorkspace method. +type DataSourcesListByWorkspaceOptions struct { + // Starting point of the collection of data source instances. + Skiptoken *string +} + +// DeletedWorkspacesListByResourceGroupOptions contains the optional parameters for the DeletedWorkspaces.ListByResourceGroup method. +type DeletedWorkspacesListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// DeletedWorkspacesListOptions contains the optional parameters for the DeletedWorkspaces.List method. +type DeletedWorkspacesListOptions struct { + // placeholder for future optional parameters +} + +// Destination properties. +type Destination struct { + // REQUIRED; The destination resource ID. This can be copied from the Properties entry of the destination resource in Azure. + ResourceID *string `json:"resourceId,omitempty"` + + // destination meta data. + MetaData *DestinationMetaData `json:"metaData,omitempty"` + + // READ-ONLY; The type of the destination resource + Type *Type `json:"type,omitempty" azure:"ro"` +} + +// DestinationMetaData - Destination meta data. +type DestinationMetaData struct { + // Optional. Allows to define an Event Hub name. Not applicable when destination is Storage Account. + EventHubName *string `json:"eventHubName,omitempty"` +} + +// ErrorAdditionalInfo - The resource management error additional info. +type ErrorAdditionalInfo struct { + // READ-ONLY; The additional info. + Info map[string]interface{} `json:"info,omitempty" azure:"ro"` + + // READ-ONLY; The additional info type. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// ErrorDetail - The error detail. +type ErrorDetail struct { + // READ-ONLY; The error additional info. + AdditionalInfo []*ErrorAdditionalInfo `json:"additionalInfo,omitempty" azure:"ro"` + + // READ-ONLY; The error code. + Code *string `json:"code,omitempty" azure:"ro"` + + // READ-ONLY; The error details. + Details []*ErrorDetail `json:"details,omitempty" azure:"ro"` + + // READ-ONLY; The error message. + Message *string `json:"message,omitempty" azure:"ro"` + + // READ-ONLY; The error target. + Target *string `json:"target,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorDetail. +func (e ErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "additionalInfo", e.AdditionalInfo) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + populate(objectMap, "target", e.Target) + return json.Marshal(objectMap) +} + +// ErrorResponse - Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData +// error response format.). +// Implements the error and azcore.HTTPResponse interfaces. +type ErrorResponse struct { + raw string + // The error object. + InnerError *ErrorDetail `json:"error,omitempty"` +} + +// Error implements the error interface for type ErrorResponse. +// The contents of the error text are not contractual and subject to change. +func (e ErrorResponse) Error() string { + return e.raw +} + +// GatewaysDeleteOptions contains the optional parameters for the Gateways.Delete method. +type GatewaysDeleteOptions struct { + // placeholder for future optional parameters +} + +// Identity for the resource. +type Identity struct { + // REQUIRED; Type of managed service identity. + Type *IdentityType `json:"type,omitempty"` + + // The list of user identities associated with the resource. The user identity dictionary key references will be ARM resource ids in the form: + // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + UserAssignedIdentities map[string]*UserIdentityProperties `json:"userAssignedIdentities,omitempty"` + + // READ-ONLY; The principal ID of resource identity. + PrincipalID *string `json:"principalId,omitempty" azure:"ro"` + + // READ-ONLY; The tenant ID of resource. + TenantID *string `json:"tenantId,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Identity. +func (i Identity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "principalId", i.PrincipalID) + populate(objectMap, "tenantId", i.TenantID) + populate(objectMap, "type", i.Type) + populate(objectMap, "userAssignedIdentities", i.UserAssignedIdentities) + return json.Marshal(objectMap) +} + +// IntelligencePack - Intelligence Pack containing a string name and boolean indicating if it's enabled. +type IntelligencePack struct { + // The display name of the intelligence pack. + DisplayName *string `json:"displayName,omitempty"` + + // The enabled boolean for the intelligence pack. + Enabled *bool `json:"enabled,omitempty"` + + // The name of the intelligence pack. + Name *string `json:"name,omitempty"` +} + +// IntelligencePacksDisableOptions contains the optional parameters for the IntelligencePacks.Disable method. +type IntelligencePacksDisableOptions struct { + // placeholder for future optional parameters +} + +// IntelligencePacksEnableOptions contains the optional parameters for the IntelligencePacks.Enable method. +type IntelligencePacksEnableOptions struct { + // placeholder for future optional parameters +} + +// IntelligencePacksListOptions contains the optional parameters for the IntelligencePacks.List method. +type IntelligencePacksListOptions struct { + // placeholder for future optional parameters +} + +// KeyVaultProperties - The key vault properties. +type KeyVaultProperties struct { + // The name of the key associated with the Log Analytics cluster. + KeyName *string `json:"keyName,omitempty"` + + // Selected key minimum required size. + KeyRsaSize *int32 `json:"keyRsaSize,omitempty"` + + // The Key Vault uri which holds they key associated with the Log Analytics cluster. + KeyVaultURI *string `json:"keyVaultUri,omitempty"` + + // The version of the key associated with the Log Analytics cluster. + KeyVersion *string `json:"keyVersion,omitempty"` +} + +// LinkedService - The top level Linked service resource container. +type LinkedService struct { + ProxyResource + // REQUIRED; The properties of the linked service. + Properties *LinkedServiceProperties `json:"properties,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type LinkedService. +func (l LinkedService) MarshalJSON() ([]byte, error) { + objectMap := l.ProxyResource.marshalInternal() + populate(objectMap, "properties", l.Properties) + populate(objectMap, "tags", l.Tags) + return json.Marshal(objectMap) +} + +// LinkedServiceListResult - The list linked service operation response. +type LinkedServiceListResult struct { + // The list of linked service instances + Value []*LinkedService `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type LinkedServiceListResult. +func (l LinkedServiceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", l.Value) + return json.Marshal(objectMap) +} + +// LinkedServiceProperties - Linked service properties. +type LinkedServiceProperties struct { + // The provisioning state of the linked service. + ProvisioningState *LinkedServiceEntityStatus `json:"provisioningState,omitempty"` + + // The resource id of the resource that will be linked to the workspace. This should be used for linking resources which require read access + ResourceID *string `json:"resourceId,omitempty"` + + // The resource id of the resource that will be linked to the workspace. This should be used for linking resources which require write access + WriteAccessResourceID *string `json:"writeAccessResourceId,omitempty"` +} + +// LinkedServicesBeginCreateOrUpdateOptions contains the optional parameters for the LinkedServices.BeginCreateOrUpdate method. +type LinkedServicesBeginCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// LinkedServicesBeginDeleteOptions contains the optional parameters for the LinkedServices.BeginDelete method. +type LinkedServicesBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// LinkedServicesGetOptions contains the optional parameters for the LinkedServices.Get method. +type LinkedServicesGetOptions struct { + // placeholder for future optional parameters +} + +// LinkedServicesListByWorkspaceOptions contains the optional parameters for the LinkedServices.ListByWorkspace method. +type LinkedServicesListByWorkspaceOptions struct { + // placeholder for future optional parameters +} + +// LinkedStorageAccountsCreateOrUpdateOptions contains the optional parameters for the LinkedStorageAccounts.CreateOrUpdate method. +type LinkedStorageAccountsCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// LinkedStorageAccountsDeleteOptions contains the optional parameters for the LinkedStorageAccounts.Delete method. +type LinkedStorageAccountsDeleteOptions struct { + // placeholder for future optional parameters +} + +// LinkedStorageAccountsGetOptions contains the optional parameters for the LinkedStorageAccounts.Get method. +type LinkedStorageAccountsGetOptions struct { + // placeholder for future optional parameters +} + +// LinkedStorageAccountsListByWorkspaceOptions contains the optional parameters for the LinkedStorageAccounts.ListByWorkspace method. +type LinkedStorageAccountsListByWorkspaceOptions struct { + // placeholder for future optional parameters +} + +// LinkedStorageAccountsListResult - The list linked storage accounts service operation response. +type LinkedStorageAccountsListResult struct { + // A list of linked storage accounts instances. + Value []*LinkedStorageAccountsResource `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type LinkedStorageAccountsListResult. +func (l LinkedStorageAccountsListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", l.Value) + return json.Marshal(objectMap) +} + +// LinkedStorageAccountsProperties - Linked storage accounts properties. +type LinkedStorageAccountsProperties struct { + // Linked storage accounts resources ids. + StorageAccountIDs []*string `json:"storageAccountIds,omitempty"` + + // READ-ONLY; Linked storage accounts type. + DataSourceType *DataSourceType `json:"dataSourceType,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type LinkedStorageAccountsProperties. +func (l LinkedStorageAccountsProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "dataSourceType", l.DataSourceType) + populate(objectMap, "storageAccountIds", l.StorageAccountIDs) + return json.Marshal(objectMap) +} + +// LinkedStorageAccountsResource - Linked storage accounts top level resource container. +type LinkedStorageAccountsResource struct { + ProxyResource + // REQUIRED; Linked storage accounts properties. + Properties *LinkedStorageAccountsProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type LinkedStorageAccountsResource. +func (l LinkedStorageAccountsResource) MarshalJSON() ([]byte, error) { + objectMap := l.ProxyResource.marshalInternal() + populate(objectMap, "properties", l.Properties) + return json.Marshal(objectMap) +} + +// ManagementGroup - A management group that is connected to a workspace +type ManagementGroup struct { + // The properties of the management group. + Properties *ManagementGroupProperties `json:"properties,omitempty"` +} + +// ManagementGroupProperties - Management group properties. +type ManagementGroupProperties struct { + // The datetime that the management group was created. + Created *time.Time `json:"created,omitempty"` + + // The last datetime that the management group received data. + DataReceived *time.Time `json:"dataReceived,omitempty"` + + // The unique ID of the management group. + ID *string `json:"id,omitempty"` + + // Gets or sets a value indicating whether the management group is a gateway. + IsGateway *bool `json:"isGateway,omitempty"` + + // The name of the management group. + Name *string `json:"name,omitempty"` + + // The SKU of System Center that is managing the management group. + SKU *string `json:"sku,omitempty"` + + // The number of servers connected to the management group. + ServerCount *int32 `json:"serverCount,omitempty"` + + // The version of System Center that is managing the management group. + Version *string `json:"version,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ManagementGroupProperties. +func (m ManagementGroupProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "created", (*timeRFC3339)(m.Created)) + populate(objectMap, "dataReceived", (*timeRFC3339)(m.DataReceived)) + populate(objectMap, "id", m.ID) + populate(objectMap, "isGateway", m.IsGateway) + populate(objectMap, "name", m.Name) + populate(objectMap, "sku", m.SKU) + populate(objectMap, "serverCount", m.ServerCount) + populate(objectMap, "version", m.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagementGroupProperties. +func (m *ManagementGroupProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "created": + var aux timeRFC3339 + err = unpopulate(val, &aux) + m.Created = (*time.Time)(&aux) + delete(rawMsg, key) + case "dataReceived": + var aux timeRFC3339 + err = unpopulate(val, &aux) + m.DataReceived = (*time.Time)(&aux) + delete(rawMsg, key) + case "id": + err = unpopulate(val, &m.ID) + delete(rawMsg, key) + case "isGateway": + err = unpopulate(val, &m.IsGateway) + delete(rawMsg, key) + case "name": + err = unpopulate(val, &m.Name) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, &m.SKU) + delete(rawMsg, key) + case "serverCount": + err = unpopulate(val, &m.ServerCount) + delete(rawMsg, key) + case "version": + err = unpopulate(val, &m.Version) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// ManagementGroupsListOptions contains the optional parameters for the ManagementGroups.List method. +type ManagementGroupsListOptions struct { + // placeholder for future optional parameters +} + +// MetricName - The name of a metric. +type MetricName struct { + // The localized name of the metric. + LocalizedValue *string `json:"localizedValue,omitempty"` + + // The system name of the metric. + Value *string `json:"value,omitempty"` +} + +// Operation - Supported operation of OperationalInsights resource provider. +type Operation struct { + // Display metadata associated with the operation. + Display *OperationDisplay `json:"display,omitempty"` + + // Operation name: {provider}/{resource}/{operation} + Name *string `json:"name,omitempty"` +} + +// OperationDisplay - Display metadata associated with the operation. +type OperationDisplay struct { + // Description of operation + Description *string `json:"description,omitempty"` + + // Type of operation: get, read, delete, etc. + Operation *string `json:"operation,omitempty"` + + // Service provider: Microsoft OperationsManagement. + Provider *string `json:"provider,omitempty"` + + // Resource on which the operation is performed etc. + Resource *string `json:"resource,omitempty"` +} + +// OperationListResult - Result of the request to list solution operations. +type OperationListResult struct { + // List of solution operations supported by the OperationsManagement resource provider. + Value []*Operation `json:"value,omitempty"` + + // READ-ONLY; URL to get the next set of operation list results if there are any. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// OperationStatus - The status of operation. +type OperationStatus struct { + // The end time of the operation. + EndTime *string `json:"endTime,omitempty"` + + // The error detail of the operation if any. + Error *ErrorResponse `json:"error,omitempty"` + + // The operation Id. + ID *string `json:"id,omitempty"` + + // The operation name. + Name *string `json:"name,omitempty"` + + // The start time of the operation. + StartTime *string `json:"startTime,omitempty"` + + // The status of the operation. + Status *string `json:"status,omitempty"` +} + +// OperationStatusesGetOptions contains the optional parameters for the OperationStatuses.Get method. +type OperationStatusesGetOptions struct { + // placeholder for future optional parameters +} + +// OperationsListOptions contains the optional parameters for the Operations.List method. +type OperationsListOptions struct { + // placeholder for future optional parameters +} + +// PrivateLinkScopedResource - The private link scope resource reference. +type PrivateLinkScopedResource struct { + // The full resource Id of the private link scope resource. + ResourceID *string `json:"resourceId,omitempty"` + + // The private link scope unique Identifier. + ScopeID *string `json:"scopeId,omitempty"` +} + +// ProxyResource - The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location +type ProxyResource struct { + Resource +} + +func (p ProxyResource) marshalInternal() map[string]interface{} { + objectMap := p.Resource.marshalInternal() + return objectMap +} + +// Resource - Common fields that are returned in the response for all Azure Resource Manager resources +type Resource struct { + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := r.marshalInternal() + return json.Marshal(objectMap) +} + +func (r Resource) marshalInternal() map[string]interface{} { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "type", r.Type) + return objectMap +} + +// SavedSearch - Value object for saved search results. +type SavedSearch struct { + ProxyResource + // REQUIRED; The properties of the saved search. + Properties *SavedSearchProperties `json:"properties,omitempty"` + + // The ETag of the saved search. To override an existing saved search, use "*" or specify the current Etag + Etag *string `json:"etag,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type SavedSearch. +func (s SavedSearch) MarshalJSON() ([]byte, error) { + objectMap := s.ProxyResource.marshalInternal() + populate(objectMap, "etag", s.Etag) + populate(objectMap, "properties", s.Properties) + return json.Marshal(objectMap) +} + +// SavedSearchProperties - Value object for saved search results. +type SavedSearchProperties struct { + // REQUIRED; The category of the saved search. This helps the user to find a saved search faster. + Category *string `json:"category,omitempty"` + + // REQUIRED; Saved search display name. + DisplayName *string `json:"displayName,omitempty"` + + // REQUIRED; The query expression for the saved search. + Query *string `json:"query,omitempty"` + + // The function alias if query serves as a function. + FunctionAlias *string `json:"functionAlias,omitempty"` + + // The optional function parameters if query serves as a function. Value should be in the following format: 'param-name1:type1 = defaultvalue1, param-name2:type2 + // = defaultvalue2'. For more examples and + // proper syntax please refer to https://docs.microsoft.com/en-us/azure/kusto/query/functions/user-defined-functions. + FunctionParameters *string `json:"functionParameters,omitempty"` + + // The tags attached to the saved search. + Tags []*Tag `json:"tags,omitempty"` + + // The version number of the query language. The current version is 2 and is the default. + Version *int64 `json:"version,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type SavedSearchProperties. +func (s SavedSearchProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "category", s.Category) + populate(objectMap, "displayName", s.DisplayName) + populate(objectMap, "functionAlias", s.FunctionAlias) + populate(objectMap, "functionParameters", s.FunctionParameters) + populate(objectMap, "query", s.Query) + populate(objectMap, "tags", s.Tags) + populate(objectMap, "version", s.Version) + return json.Marshal(objectMap) +} + +// SavedSearchesCreateOrUpdateOptions contains the optional parameters for the SavedSearches.CreateOrUpdate method. +type SavedSearchesCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// SavedSearchesDeleteOptions contains the optional parameters for the SavedSearches.Delete method. +type SavedSearchesDeleteOptions struct { + // placeholder for future optional parameters +} + +// SavedSearchesGetOptions contains the optional parameters for the SavedSearches.Get method. +type SavedSearchesGetOptions struct { + // placeholder for future optional parameters +} + +// SavedSearchesListByWorkspaceOptions contains the optional parameters for the SavedSearches.ListByWorkspace method. +type SavedSearchesListByWorkspaceOptions struct { + // placeholder for future optional parameters +} + +// SavedSearchesListResult - The saved search list operation response. +type SavedSearchesListResult struct { + // The array of result values. + Value []*SavedSearch `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type SavedSearchesListResult. +func (s SavedSearchesListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// SchemaGetOptions contains the optional parameters for the Schema.Get method. +type SchemaGetOptions struct { + // placeholder for future optional parameters +} + +// SearchGetSchemaResponse - The get schema operation response. +type SearchGetSchemaResponse struct { + // The metadata from search results. + Metadata *SearchMetadata `json:"metadata,omitempty"` + + // The array of result values. + Value []*SearchSchemaValue `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type SearchGetSchemaResponse. +func (s SearchGetSchemaResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "metadata", s.Metadata) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// SearchMetadata - Metadata for search results. +type SearchMetadata struct { + // The aggregated grouping fields. + AggregatedGroupingFields *string `json:"aggregatedGroupingFields,omitempty"` + + // The aggregated value field. + AggregatedValueField *string `json:"aggregatedValueField,omitempty"` + + // The core summaries. + CoreSummaries []*CoreSummary `json:"coreSummaries,omitempty"` + + // The ETag of the search results. + ETag *string `json:"eTag,omitempty"` + + // The id of the search results request. + ID *string `json:"id,omitempty"` + + // The time of last update. + LastUpdated *time.Time `json:"lastUpdated,omitempty"` + + // The max of all aggregates returned in the result set. + Max *int64 `json:"max,omitempty"` + + // The request time. + RequestTime *int64 `json:"requestTime,omitempty"` + + // The search result type. + ResultType *string `json:"resultType,omitempty"` + + // The schema. + Schema *SearchMetadataSchema `json:"schema,omitempty"` + + // The request id of the search. + SearchID *string `json:"requestId,omitempty"` + + // How the results are sorted. + Sort []*SearchSort `json:"sort,omitempty"` + + // The start time for the search. + StartTime *time.Time `json:"startTime,omitempty"` + + // The status of the search results. + Status *string `json:"status,omitempty"` + + // The sum of all aggregates returned in the result set. + Sum *int64 `json:"sum,omitempty"` + + // The number of top search results. + Top *int64 `json:"top,omitempty"` + + // The total number of search results. + Total *int64 `json:"total,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type SearchMetadata. +func (s SearchMetadata) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "aggregatedGroupingFields", s.AggregatedGroupingFields) + populate(objectMap, "aggregatedValueField", s.AggregatedValueField) + populate(objectMap, "coreSummaries", s.CoreSummaries) + populate(objectMap, "eTag", s.ETag) + populate(objectMap, "id", s.ID) + populate(objectMap, "lastUpdated", (*timeRFC3339)(s.LastUpdated)) + populate(objectMap, "max", s.Max) + populate(objectMap, "requestTime", s.RequestTime) + populate(objectMap, "resultType", s.ResultType) + populate(objectMap, "schema", s.Schema) + populate(objectMap, "requestId", s.SearchID) + populate(objectMap, "sort", s.Sort) + populate(objectMap, "startTime", (*timeRFC3339)(s.StartTime)) + populate(objectMap, "status", s.Status) + populate(objectMap, "sum", s.Sum) + populate(objectMap, "top", s.Top) + populate(objectMap, "total", s.Total) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SearchMetadata. +func (s *SearchMetadata) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "aggregatedGroupingFields": + err = unpopulate(val, &s.AggregatedGroupingFields) + delete(rawMsg, key) + case "aggregatedValueField": + err = unpopulate(val, &s.AggregatedValueField) + delete(rawMsg, key) + case "coreSummaries": + err = unpopulate(val, &s.CoreSummaries) + delete(rawMsg, key) + case "eTag": + err = unpopulate(val, &s.ETag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, &s.ID) + delete(rawMsg, key) + case "lastUpdated": + var aux timeRFC3339 + err = unpopulate(val, &aux) + s.LastUpdated = (*time.Time)(&aux) + delete(rawMsg, key) + case "max": + err = unpopulate(val, &s.Max) + delete(rawMsg, key) + case "requestTime": + err = unpopulate(val, &s.RequestTime) + delete(rawMsg, key) + case "resultType": + err = unpopulate(val, &s.ResultType) + delete(rawMsg, key) + case "schema": + err = unpopulate(val, &s.Schema) + delete(rawMsg, key) + case "requestId": + err = unpopulate(val, &s.SearchID) + delete(rawMsg, key) + case "sort": + err = unpopulate(val, &s.Sort) + delete(rawMsg, key) + case "startTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + s.StartTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "status": + err = unpopulate(val, &s.Status) + delete(rawMsg, key) + case "sum": + err = unpopulate(val, &s.Sum) + delete(rawMsg, key) + case "top": + err = unpopulate(val, &s.Top) + delete(rawMsg, key) + case "total": + err = unpopulate(val, &s.Total) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// SearchMetadataSchema - Schema metadata for search. +type SearchMetadataSchema struct { + // The name of the metadata schema. + Name *string `json:"name,omitempty"` + + // The version of the metadata schema. + Version *int32 `json:"version,omitempty"` +} + +// SearchSchemaValue - Value object for schema results. +type SearchSchemaValue struct { + // REQUIRED; The boolean that indicates whether or not the field is a facet. + Facet *bool `json:"facet,omitempty"` + + // REQUIRED; The boolean that indicates the field is searchable as free text. + Indexed *bool `json:"indexed,omitempty"` + + // REQUIRED; The boolean that indicates whether or not the field is stored. + Stored *bool `json:"stored,omitempty"` + + // The display name of the schema. + DisplayName *string `json:"displayName,omitempty"` + + // The name of the schema. + Name *string `json:"name,omitempty"` + + // The array of workflows containing the field. + OwnerType []*string `json:"ownerType,omitempty"` + + // The type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type SearchSchemaValue. +func (s SearchSchemaValue) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "displayName", s.DisplayName) + populate(objectMap, "facet", s.Facet) + populate(objectMap, "indexed", s.Indexed) + populate(objectMap, "name", s.Name) + populate(objectMap, "ownerType", s.OwnerType) + populate(objectMap, "stored", s.Stored) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// SearchSort - The sort parameters for search. +type SearchSort struct { + // The name of the field the search query is sorted on. + Name *string `json:"name,omitempty"` + + // The sort order of the search. + Order *SearchSortEnum `json:"order,omitempty"` +} + +// SharedKeys - The shared keys for a workspace. +type SharedKeys struct { + // The primary shared key of a workspace. + PrimarySharedKey *string `json:"primarySharedKey,omitempty"` + + // The secondary shared key of a workspace. + SecondarySharedKey *string `json:"secondarySharedKey,omitempty"` +} + +// SharedKeysGetSharedKeysOptions contains the optional parameters for the SharedKeys.GetSharedKeys method. +type SharedKeysGetSharedKeysOptions struct { + // placeholder for future optional parameters +} + +// SharedKeysRegenerateOptions contains the optional parameters for the SharedKeys.Regenerate method. +type SharedKeysRegenerateOptions struct { + // placeholder for future optional parameters +} + +// StorageAccount - Describes a storage account connection. +type StorageAccount struct { + // REQUIRED; The Azure Resource Manager ID of the storage account resource. + ID *string `json:"id,omitempty"` + + // REQUIRED; The storage account key. + Key *string `json:"key,omitempty"` +} + +// StorageInsight - The top level storage insight resource container. +type StorageInsight struct { + ProxyResource + // The ETag of the storage insight. + ETag *string `json:"eTag,omitempty"` + + // Storage insight properties. + Properties *StorageInsightProperties `json:"properties,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type StorageInsight. +func (s StorageInsight) MarshalJSON() ([]byte, error) { + objectMap := s.ProxyResource.marshalInternal() + populate(objectMap, "eTag", s.ETag) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "tags", s.Tags) + return json.Marshal(objectMap) +} + +// StorageInsightConfigsCreateOrUpdateOptions contains the optional parameters for the StorageInsightConfigs.CreateOrUpdate method. +type StorageInsightConfigsCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// StorageInsightConfigsDeleteOptions contains the optional parameters for the StorageInsightConfigs.Delete method. +type StorageInsightConfigsDeleteOptions struct { + // placeholder for future optional parameters +} + +// StorageInsightConfigsGetOptions contains the optional parameters for the StorageInsightConfigs.Get method. +type StorageInsightConfigsGetOptions struct { + // placeholder for future optional parameters +} + +// StorageInsightConfigsListByWorkspaceOptions contains the optional parameters for the StorageInsightConfigs.ListByWorkspace method. +type StorageInsightConfigsListByWorkspaceOptions struct { + // placeholder for future optional parameters +} + +// StorageInsightListResult - The list storage insights operation response. +type StorageInsightListResult struct { + // The link (url) to the next page of results. + OdataNextLink *string `json:"@odata.nextLink,omitempty"` + + // A list of storage insight items. + Value []*StorageInsight `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type StorageInsightListResult. +func (s StorageInsightListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "@odata.nextLink", s.OdataNextLink) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// StorageInsightProperties - Storage insight properties. +type StorageInsightProperties struct { + // REQUIRED; The storage account connection details + StorageAccount *StorageAccount `json:"storageAccount,omitempty"` + + // The names of the blob containers that the workspace should read + Containers []*string `json:"containers,omitempty"` + + // The names of the Azure tables that the workspace should read + Tables []*string `json:"tables,omitempty"` + + // READ-ONLY; The status of the storage insight + Status *StorageInsightStatus `json:"status,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type StorageInsightProperties. +func (s StorageInsightProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "containers", s.Containers) + populate(objectMap, "status", s.Status) + populate(objectMap, "storageAccount", s.StorageAccount) + populate(objectMap, "tables", s.Tables) + return json.Marshal(objectMap) +} + +// StorageInsightStatus - The status of the storage insight. +type StorageInsightStatus struct { + // REQUIRED; The state of the storage insight connection to the workspace + State *StorageInsightState `json:"state,omitempty"` + + // Description of the state of the storage insight. + Description *string `json:"description,omitempty"` +} + +// Table - Workspace data table definition. +type Table struct { + ProxyResource + // Table properties. + Properties *TableProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type Table. +func (t Table) MarshalJSON() ([]byte, error) { + objectMap := t.ProxyResource.marshalInternal() + populate(objectMap, "properties", t.Properties) + return json.Marshal(objectMap) +} + +// TableProperties - Table properties. +type TableProperties struct { + // The data table data retention in days, between 30 and 730. Setting this property to null will default to the workspace retention. + RetentionInDays *int32 `json:"retentionInDays,omitempty"` +} + +// TablesGetOptions contains the optional parameters for the Tables.Get method. +type TablesGetOptions struct { + // placeholder for future optional parameters +} + +// TablesListByWorkspaceOptions contains the optional parameters for the Tables.ListByWorkspace method. +type TablesListByWorkspaceOptions struct { + // placeholder for future optional parameters +} + +// TablesListResult - The list tables operation response. +type TablesListResult struct { + // A list of data tables. + Value []*Table `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TablesListResult. +func (t TablesListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", t.Value) + return json.Marshal(objectMap) +} + +// TablesUpdateOptions contains the optional parameters for the Tables.Update method. +type TablesUpdateOptions struct { + // placeholder for future optional parameters +} + +// Tag - A tag of a saved search. +type Tag struct { + // REQUIRED; The tag name. + Name *string `json:"name,omitempty"` + + // REQUIRED; The tag value. + Value *string `json:"value,omitempty"` +} + +// TrackedResource - The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location' +type TrackedResource struct { + Resource + // REQUIRED; The geo-location where the resource lives + Location *string `json:"location,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TrackedResource. +func (t TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := t.marshalInternal() + return json.Marshal(objectMap) +} + +func (t TrackedResource) marshalInternal() map[string]interface{} { + objectMap := t.Resource.marshalInternal() + populate(objectMap, "location", t.Location) + populate(objectMap, "tags", t.Tags) + return objectMap +} + +// UsageMetric - A metric describing the usage of a resource. +type UsageMetric struct { + // The current value of the metric. + CurrentValue *float64 `json:"currentValue,omitempty"` + + // The quota limit for the metric. + Limit *float64 `json:"limit,omitempty"` + + // The name of the metric. + Name *MetricName `json:"name,omitempty"` + + // The time that the metric's value will reset. + NextResetTime *time.Time `json:"nextResetTime,omitempty"` + + // The quota period that determines the length of time between value resets. + QuotaPeriod *string `json:"quotaPeriod,omitempty"` + + // The units used for the metric. + Unit *string `json:"unit,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type UsageMetric. +func (u UsageMetric) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "currentValue", u.CurrentValue) + populate(objectMap, "limit", u.Limit) + populate(objectMap, "name", u.Name) + populate(objectMap, "nextResetTime", (*timeRFC3339)(u.NextResetTime)) + populate(objectMap, "quotaPeriod", u.QuotaPeriod) + populate(objectMap, "unit", u.Unit) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UsageMetric. +func (u *UsageMetric) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "currentValue": + err = unpopulate(val, &u.CurrentValue) + delete(rawMsg, key) + case "limit": + err = unpopulate(val, &u.Limit) + delete(rawMsg, key) + case "name": + err = unpopulate(val, &u.Name) + delete(rawMsg, key) + case "nextResetTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + u.NextResetTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "quotaPeriod": + err = unpopulate(val, &u.QuotaPeriod) + delete(rawMsg, key) + case "unit": + err = unpopulate(val, &u.Unit) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// UsagesListOptions contains the optional parameters for the Usages.List method. +type UsagesListOptions struct { + // placeholder for future optional parameters +} + +// UserIdentityProperties - User assigned identity properties. +type UserIdentityProperties struct { + // READ-ONLY; The client id of user assigned identity. + ClientID *string `json:"clientId,omitempty" azure:"ro"` + + // READ-ONLY; The principal id of user assigned identity. + PrincipalID *string `json:"principalId,omitempty" azure:"ro"` +} + +// Workspace - The top level Workspace resource container. +type Workspace struct { + TrackedResource + // The ETag of the workspace. + ETag *string `json:"eTag,omitempty"` + + // Workspace properties. + Properties *WorkspaceProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type Workspace. +func (w Workspace) MarshalJSON() ([]byte, error) { + objectMap := w.TrackedResource.marshalInternal() + populate(objectMap, "eTag", w.ETag) + populate(objectMap, "properties", w.Properties) + return json.Marshal(objectMap) +} + +// WorkspaceCapping - The daily volume cap for ingestion. +type WorkspaceCapping struct { + // The workspace daily quota for ingestion. + DailyQuotaGb *float64 `json:"dailyQuotaGb,omitempty"` + + // READ-ONLY; The status of data ingestion for this workspace. + DataIngestionStatus *DataIngestionStatus `json:"dataIngestionStatus,omitempty" azure:"ro"` + + // READ-ONLY; The time when the quota will be rest. + QuotaNextResetTime *string `json:"quotaNextResetTime,omitempty" azure:"ro"` +} + +// WorkspaceFeatures - Workspace features. +type WorkspaceFeatures struct { + // OPTIONAL; Contains additional key/value pairs not defined in the schema. + AdditionalProperties map[string]interface{} + + // Dedicated LA cluster resourceId that is linked to the workspaces. + ClusterResourceID *string `json:"clusterResourceId,omitempty"` + + // Disable Non-AAD based Auth. + DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` + + // Flag that indicate if data should be exported. + EnableDataExport *bool `json:"enableDataExport,omitempty"` + + // Flag that indicate which permission to use - resource or workspace or both. + EnableLogAccessUsingOnlyResourcePermissions *bool `json:"enableLogAccessUsingOnlyResourcePermissions,omitempty"` + + // Flag that describes if we want to remove the data after 30 days. + ImmediatePurgeDataOn30Days *bool `json:"immediatePurgeDataOn30Days,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type WorkspaceFeatures. +func (w WorkspaceFeatures) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "clusterResourceId", w.ClusterResourceID) + populate(objectMap, "disableLocalAuth", w.DisableLocalAuth) + populate(objectMap, "enableDataExport", w.EnableDataExport) + populate(objectMap, "enableLogAccessUsingOnlyResourcePermissions", w.EnableLogAccessUsingOnlyResourcePermissions) + populate(objectMap, "immediatePurgeDataOn30Days", w.ImmediatePurgeDataOn30Days) + if w.AdditionalProperties != nil { + for key, val := range w.AdditionalProperties { + objectMap[key] = val + } + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WorkspaceFeatures. +func (w *WorkspaceFeatures) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "clusterResourceId": + err = unpopulate(val, &w.ClusterResourceID) + delete(rawMsg, key) + case "disableLocalAuth": + err = unpopulate(val, &w.DisableLocalAuth) + delete(rawMsg, key) + case "enableDataExport": + err = unpopulate(val, &w.EnableDataExport) + delete(rawMsg, key) + case "enableLogAccessUsingOnlyResourcePermissions": + err = unpopulate(val, &w.EnableLogAccessUsingOnlyResourcePermissions) + delete(rawMsg, key) + case "immediatePurgeDataOn30Days": + err = unpopulate(val, &w.ImmediatePurgeDataOn30Days) + delete(rawMsg, key) + default: + if w.AdditionalProperties == nil { + w.AdditionalProperties = map[string]interface{}{} + } + if val != nil { + var aux interface{} + err = json.Unmarshal(val, &aux) + w.AdditionalProperties[key] = aux + } + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// WorkspaceListManagementGroupsResult - The list workspace management groups operation response. +type WorkspaceListManagementGroupsResult struct { + // Gets or sets a list of management groups attached to the workspace. + Value []*ManagementGroup `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type WorkspaceListManagementGroupsResult. +func (w WorkspaceListManagementGroupsResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", w.Value) + return json.Marshal(objectMap) +} + +// WorkspaceListResult - The list workspaces operation response. +type WorkspaceListResult struct { + // A list of workspaces. + Value []*Workspace `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type WorkspaceListResult. +func (w WorkspaceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", w.Value) + return json.Marshal(objectMap) +} + +// WorkspaceListUsagesResult - The list workspace usages operation response. +type WorkspaceListUsagesResult struct { + // Gets or sets a list of usage metrics for a workspace. + Value []*UsageMetric `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type WorkspaceListUsagesResult. +func (w WorkspaceListUsagesResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", w.Value) + return json.Marshal(objectMap) +} + +// WorkspacePatch - The top level Workspace resource container. +type WorkspacePatch struct { + AzureEntityResource + // Workspace properties. + Properties *WorkspaceProperties `json:"properties,omitempty"` + + // Resource tags. Optional. + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type WorkspacePatch. +func (w WorkspacePatch) MarshalJSON() ([]byte, error) { + objectMap := w.AzureEntityResource.marshalInternal() + populate(objectMap, "properties", w.Properties) + populate(objectMap, "tags", w.Tags) + return json.Marshal(objectMap) +} + +// WorkspaceProperties - Workspace properties. +type WorkspaceProperties struct { + // Workspace features. + Features *WorkspaceFeatures `json:"features,omitempty"` + + // Indicates whether customer managed storage is mandatory for query management. + ForceCmkForQuery *bool `json:"forceCmkForQuery,omitempty"` + + // The provisioning state of the workspace. + ProvisioningState *WorkspaceEntityStatus `json:"provisioningState,omitempty"` + + // The network access type for accessing Log Analytics ingestion. + PublicNetworkAccessForIngestion *PublicNetworkAccessType `json:"publicNetworkAccessForIngestion,omitempty"` + + // The network access type for accessing Log Analytics query. + PublicNetworkAccessForQuery *PublicNetworkAccessType `json:"publicNetworkAccessForQuery,omitempty"` + + // The workspace data retention in days. Allowed values are per pricing plan. See pricing tiers documentation for details. + RetentionInDays *int32 `json:"retentionInDays,omitempty"` + + // The SKU of the workspace. + SKU *WorkspaceSKU `json:"sku,omitempty"` + + // The daily volume cap for ingestion. + WorkspaceCapping *WorkspaceCapping `json:"workspaceCapping,omitempty"` + + // READ-ONLY; Workspace creation date. + CreatedDate *string `json:"createdDate,omitempty" azure:"ro"` + + // READ-ONLY; This is a read-only property. Represents the ID associated with the workspace. + CustomerID *string `json:"customerId,omitempty" azure:"ro"` + + // READ-ONLY; Workspace modification date. + ModifiedDate *string `json:"modifiedDate,omitempty" azure:"ro"` + + // READ-ONLY; List of linked private link scope resources. + PrivateLinkScopedResources []*PrivateLinkScopedResource `json:"privateLinkScopedResources,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type WorkspaceProperties. +func (w WorkspaceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "createdDate", w.CreatedDate) + populate(objectMap, "customerId", w.CustomerID) + populate(objectMap, "features", w.Features) + populate(objectMap, "forceCmkForQuery", w.ForceCmkForQuery) + populate(objectMap, "modifiedDate", w.ModifiedDate) + populate(objectMap, "privateLinkScopedResources", w.PrivateLinkScopedResources) + populate(objectMap, "provisioningState", w.ProvisioningState) + populate(objectMap, "publicNetworkAccessForIngestion", w.PublicNetworkAccessForIngestion) + populate(objectMap, "publicNetworkAccessForQuery", w.PublicNetworkAccessForQuery) + populate(objectMap, "retentionInDays", w.RetentionInDays) + populate(objectMap, "sku", w.SKU) + populate(objectMap, "workspaceCapping", w.WorkspaceCapping) + return json.Marshal(objectMap) +} + +// WorkspacePurgeBody - Describes the body of a purge request for an App Insights Workspace +type WorkspacePurgeBody struct { + // REQUIRED; The set of columns and filters (queries) to run over them to purge the resulting data. + Filters []*WorkspacePurgeBodyFilters `json:"filters,omitempty"` + + // REQUIRED; Table from which to purge data. + Table *string `json:"table,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type WorkspacePurgeBody. +func (w WorkspacePurgeBody) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "filters", w.Filters) + populate(objectMap, "table", w.Table) + return json.Marshal(objectMap) +} + +// WorkspacePurgeBodyFilters - User-defined filters to return data which will be purged from the table. +type WorkspacePurgeBodyFilters struct { + // The column of the table over which the given query should run + Column *string `json:"column,omitempty"` + + // When filtering over custom dimensions, this key will be used as the name of the custom dimension. + Key *string `json:"key,omitempty"` + + // A query operator to evaluate over the provided column and value(s). Supported operators are ==, =~, in, in~, >, >=, <, <=, between, and have the same + // behavior as they would in a KQL query. + Operator *string `json:"operator,omitempty"` + + // the value for the operator to function over. This can be a number (e.g., > 100), a string (timestamp >= '2017-09-01') or array of values. + Value interface{} `json:"value,omitempty"` +} + +// WorkspacePurgeGetPurgeStatusOptions contains the optional parameters for the WorkspacePurge.GetPurgeStatus method. +type WorkspacePurgeGetPurgeStatusOptions struct { + // placeholder for future optional parameters +} + +// WorkspacePurgePurgeOptions contains the optional parameters for the WorkspacePurge.Purge method. +type WorkspacePurgePurgeOptions struct { + // placeholder for future optional parameters +} + +// WorkspacePurgeResponse - Response containing operationId for a specific purge action. +type WorkspacePurgeResponse struct { + // REQUIRED; 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 { + // REQUIRED; Status of the operation represented by the requested Id. + Status *PurgeState `json:"status,omitempty"` +} + +// WorkspaceSKU - The SKU (tier) of a workspace. +type WorkspaceSKU struct { + // REQUIRED; The name of the SKU. + Name *WorkspaceSKUNameEnum `json:"name,omitempty"` + + // The capacity reservation level for this workspace, when CapacityReservation sku is selected. + CapacityReservationLevel *int32 `json:"capacityReservationLevel,omitempty"` + + // READ-ONLY; The last time when the sku was updated. + LastSKUUpdate *string `json:"lastSkuUpdate,omitempty" azure:"ro"` +} + +// WorkspacesBeginCreateOrUpdateOptions contains the optional parameters for the Workspaces.BeginCreateOrUpdate method. +type WorkspacesBeginCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// WorkspacesBeginDeleteOptions contains the optional parameters for the Workspaces.BeginDelete method. +type WorkspacesBeginDeleteOptions struct { + // Deletes the workspace without the recovery option. A workspace that was deleted with this flag cannot be recovered. + Force *bool +} + +// WorkspacesGetOptions contains the optional parameters for the Workspaces.Get method. +type WorkspacesGetOptions struct { + // placeholder for future optional parameters +} + +// WorkspacesListByResourceGroupOptions contains the optional parameters for the Workspaces.ListByResourceGroup method. +type WorkspacesListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// WorkspacesListOptions contains the optional parameters for the Workspaces.List method. +type WorkspacesListOptions struct { + // placeholder for future optional parameters +} + +// WorkspacesUpdateOptions contains the optional parameters for the Workspaces.Update method. +type WorkspacesUpdateOptions struct { + // placeholder for future optional parameters +} + +func populate(m map[string]interface{}, k string, v interface{}) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, v interface{}) error { + if data == nil { + return nil + } + return json.Unmarshal(data, v) +} diff --git a/sdk/operationalinsights/armoperationalinsights/zz_generated_operations_client.go b/sdk/operationalinsights/armoperationalinsights/zz_generated_operations_client.go new file mode 100644 index 000000000000..377f7760d03d --- /dev/null +++ b/sdk/operationalinsights/armoperationalinsights/zz_generated_operations_client.go @@ -0,0 +1,78 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armoperationalinsights + +import ( + "context" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" +) + +// OperationsClient contains the methods for the Operations group. +// Don't use this type directly, use NewOperationsClient() instead. +type OperationsClient struct { + con *armcore.Connection +} + +// NewOperationsClient creates a new instance of OperationsClient with the specified values. +func NewOperationsClient(con *armcore.Connection) *OperationsClient { + return &OperationsClient{con: con} +} + +// List - Lists all of the available OperationalInsights Rest API operations. +// If the operation fails it returns the *ErrorResponse error type. +func (client *OperationsClient) List(options *OperationsListOptions) OperationsListPager { + return &operationsListPager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp OperationsListResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.OperationListResult.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsListOptions) (*azcore.Request, error) { + urlPath := "/providers/Microsoft.OperationalInsights/operations" + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-10-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *azcore.Response) (OperationsListResponse, error) { + result := OperationsListResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.OperationListResult); err != nil { + return OperationsListResponse{}, err + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *OperationsClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/operationalinsights/armoperationalinsights/zz_generated_operationstatuses_client.go b/sdk/operationalinsights/armoperationalinsights/zz_generated_operationstatuses_client.go new file mode 100644 index 000000000000..7a6de221a0fc --- /dev/null +++ b/sdk/operationalinsights/armoperationalinsights/zz_generated_operationstatuses_client.go @@ -0,0 +1,95 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armoperationalinsights + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// OperationStatusesClient contains the methods for the OperationStatuses group. +// Don't use this type directly, use NewOperationStatusesClient() instead. +type OperationStatusesClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewOperationStatusesClient creates a new instance of OperationStatusesClient with the specified values. +func NewOperationStatusesClient(con *armcore.Connection, subscriptionID string) *OperationStatusesClient { + return &OperationStatusesClient{con: con, subscriptionID: subscriptionID} +} + +// Get - Get the status of a long running azure asynchronous operation. +// If the operation fails it returns a generic error. +func (client *OperationStatusesClient) Get(ctx context.Context, location string, asyncOperationID string, options *OperationStatusesGetOptions) (OperationStatusesGetResponse, error) { + req, err := client.getCreateRequest(ctx, location, asyncOperationID, options) + if err != nil { + return OperationStatusesGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return OperationStatusesGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return OperationStatusesGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *OperationStatusesClient) getCreateRequest(ctx context.Context, location string, asyncOperationID string, options *OperationStatusesGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.OperationalInsights/locations/{location}/operationStatuses/{asyncOperationId}" + if location == "" { + return nil, errors.New("parameter location cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) + if asyncOperationID == "" { + return nil, errors.New("parameter asyncOperationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{asyncOperationId}", url.PathEscape(asyncOperationID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-08-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *OperationStatusesClient) getHandleResponse(resp *azcore.Response) (OperationStatusesGetResponse, error) { + result := OperationStatusesGetResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.OperationStatus); err != nil { + return OperationStatusesGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *OperationStatusesClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} diff --git a/sdk/operationalinsights/armoperationalinsights/zz_generated_pagers.go b/sdk/operationalinsights/armoperationalinsights/zz_generated_pagers.go new file mode 100644 index 000000000000..0d14fd0b7dcc --- /dev/null +++ b/sdk/operationalinsights/armoperationalinsights/zz_generated_pagers.go @@ -0,0 +1,290 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armoperationalinsights + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "reflect" +) + +type ClustersListByResourceGroupPager interface { + azcore.Pager + // PageResponse returns the current ClustersListByResourceGroupResponse. + PageResponse() ClustersListByResourceGroupResponse +} + +type clustersListByResourceGroupPager struct { + client *ClustersClient + current ClustersListByResourceGroupResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, ClustersListByResourceGroupResponse) (*azcore.Request, error) +} + +func (p *clustersListByResourceGroupPager) Err() error { + return p.err +} + +func (p *clustersListByResourceGroupPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ClusterListResult.NextLink == nil || len(*p.current.ClusterListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByResourceGroupHandleError(resp) + return false + } + result, err := p.client.listByResourceGroupHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *clustersListByResourceGroupPager) PageResponse() ClustersListByResourceGroupResponse { + return p.current +} + +type ClustersListPager interface { + azcore.Pager + // PageResponse returns the current ClustersListResponse. + PageResponse() ClustersListResponse +} + +type clustersListPager struct { + client *ClustersClient + current ClustersListResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, ClustersListResponse) (*azcore.Request, error) +} + +func (p *clustersListPager) Err() error { + return p.err +} + +func (p *clustersListPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ClusterListResult.NextLink == nil || len(*p.current.ClusterListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *clustersListPager) PageResponse() ClustersListResponse { + return p.current +} + +type DataSourcesListByWorkspacePager interface { + azcore.Pager + // PageResponse returns the current DataSourcesListByWorkspaceResponse. + PageResponse() DataSourcesListByWorkspaceResponse +} + +type dataSourcesListByWorkspacePager struct { + client *DataSourcesClient + current DataSourcesListByWorkspaceResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, DataSourcesListByWorkspaceResponse) (*azcore.Request, error) +} + +func (p *dataSourcesListByWorkspacePager) Err() error { + return p.err +} + +func (p *dataSourcesListByWorkspacePager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.DataSourceListResult.NextLink == nil || len(*p.current.DataSourceListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByWorkspaceHandleError(resp) + return false + } + result, err := p.client.listByWorkspaceHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *dataSourcesListByWorkspacePager) PageResponse() DataSourcesListByWorkspaceResponse { + return p.current +} + +type OperationsListPager interface { + azcore.Pager + // PageResponse returns the current OperationsListResponse. + PageResponse() OperationsListResponse +} + +type operationsListPager struct { + client *OperationsClient + current OperationsListResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, OperationsListResponse) (*azcore.Request, error) +} + +func (p *operationsListPager) Err() error { + return p.err +} + +func (p *operationsListPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.OperationListResult.NextLink == nil || len(*p.current.OperationListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *operationsListPager) PageResponse() OperationsListResponse { + return p.current +} + +type StorageInsightConfigsListByWorkspacePager interface { + azcore.Pager + // PageResponse returns the current StorageInsightConfigsListByWorkspaceResponse. + PageResponse() StorageInsightConfigsListByWorkspaceResponse +} + +type storageInsightConfigsListByWorkspacePager struct { + client *StorageInsightConfigsClient + current StorageInsightConfigsListByWorkspaceResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, StorageInsightConfigsListByWorkspaceResponse) (*azcore.Request, error) +} + +func (p *storageInsightConfigsListByWorkspacePager) Err() error { + return p.err +} + +func (p *storageInsightConfigsListByWorkspacePager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.StorageInsightListResult.OdataNextLink == nil || len(*p.current.StorageInsightListResult.OdataNextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByWorkspaceHandleError(resp) + return false + } + result, err := p.client.listByWorkspaceHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *storageInsightConfigsListByWorkspacePager) PageResponse() StorageInsightConfigsListByWorkspaceResponse { + return p.current +} diff --git a/sdk/operationalinsights/armoperationalinsights/zz_generated_pollers.go b/sdk/operationalinsights/armoperationalinsights/zz_generated_pollers.go new file mode 100644 index 000000000000..89edabee7a28 --- /dev/null +++ b/sdk/operationalinsights/armoperationalinsights/zz_generated_pollers.go @@ -0,0 +1,286 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armoperationalinsights + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "time" +) + +// ClustersCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type ClustersCreateOrUpdatePoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final ClustersCreateOrUpdateResponse will be returned. + FinalResponse(ctx context.Context) (ClustersCreateOrUpdateResponse, error) +} + +type clustersCreateOrUpdatePoller struct { + pt *armcore.LROPoller +} + +func (p *clustersCreateOrUpdatePoller) Done() bool { + return p.pt.Done() +} + +func (p *clustersCreateOrUpdatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *clustersCreateOrUpdatePoller) FinalResponse(ctx context.Context) (ClustersCreateOrUpdateResponse, error) { + respType := ClustersCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.Cluster) + if err != nil { + return ClustersCreateOrUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *clustersCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *clustersCreateOrUpdatePoller) pollUntilDone(ctx context.Context, freq time.Duration) (ClustersCreateOrUpdateResponse, error) { + respType := ClustersCreateOrUpdateResponse{} + resp, err := p.pt.PollUntilDone(ctx, freq, &respType.Cluster) + if err != nil { + return ClustersCreateOrUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ClustersDeletePoller provides polling facilities until the operation reaches a terminal state. +type ClustersDeletePoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final ClustersDeleteResponse will be returned. + FinalResponse(ctx context.Context) (ClustersDeleteResponse, error) +} + +type clustersDeletePoller struct { + pt *armcore.LROPoller +} + +func (p *clustersDeletePoller) Done() bool { + return p.pt.Done() +} + +func (p *clustersDeletePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *clustersDeletePoller) FinalResponse(ctx context.Context) (ClustersDeleteResponse, error) { + respType := ClustersDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return ClustersDeleteResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *clustersDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *clustersDeletePoller) pollUntilDone(ctx context.Context, freq time.Duration) (ClustersDeleteResponse, error) { + respType := ClustersDeleteResponse{} + resp, err := p.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return ClustersDeleteResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// LinkedServicesCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type LinkedServicesCreateOrUpdatePoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final LinkedServicesCreateOrUpdateResponse will be returned. + FinalResponse(ctx context.Context) (LinkedServicesCreateOrUpdateResponse, error) +} + +type linkedServicesCreateOrUpdatePoller struct { + pt *armcore.LROPoller +} + +func (p *linkedServicesCreateOrUpdatePoller) Done() bool { + return p.pt.Done() +} + +func (p *linkedServicesCreateOrUpdatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *linkedServicesCreateOrUpdatePoller) FinalResponse(ctx context.Context) (LinkedServicesCreateOrUpdateResponse, error) { + respType := LinkedServicesCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.LinkedService) + if err != nil { + return LinkedServicesCreateOrUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *linkedServicesCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *linkedServicesCreateOrUpdatePoller) pollUntilDone(ctx context.Context, freq time.Duration) (LinkedServicesCreateOrUpdateResponse, error) { + respType := LinkedServicesCreateOrUpdateResponse{} + resp, err := p.pt.PollUntilDone(ctx, freq, &respType.LinkedService) + if err != nil { + return LinkedServicesCreateOrUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// LinkedServicesDeletePoller provides polling facilities until the operation reaches a terminal state. +type LinkedServicesDeletePoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final LinkedServicesDeleteResponse will be returned. + FinalResponse(ctx context.Context) (LinkedServicesDeleteResponse, error) +} + +type linkedServicesDeletePoller struct { + pt *armcore.LROPoller +} + +func (p *linkedServicesDeletePoller) Done() bool { + return p.pt.Done() +} + +func (p *linkedServicesDeletePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *linkedServicesDeletePoller) FinalResponse(ctx context.Context) (LinkedServicesDeleteResponse, error) { + respType := LinkedServicesDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.LinkedService) + if err != nil { + return LinkedServicesDeleteResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *linkedServicesDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *linkedServicesDeletePoller) pollUntilDone(ctx context.Context, freq time.Duration) (LinkedServicesDeleteResponse, error) { + respType := LinkedServicesDeleteResponse{} + resp, err := p.pt.PollUntilDone(ctx, freq, &respType.LinkedService) + if err != nil { + return LinkedServicesDeleteResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// WorkspacesCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type WorkspacesCreateOrUpdatePoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final WorkspacesCreateOrUpdateResponse will be returned. + FinalResponse(ctx context.Context) (WorkspacesCreateOrUpdateResponse, error) +} + +type workspacesCreateOrUpdatePoller struct { + pt *armcore.LROPoller +} + +func (p *workspacesCreateOrUpdatePoller) Done() bool { + return p.pt.Done() +} + +func (p *workspacesCreateOrUpdatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *workspacesCreateOrUpdatePoller) FinalResponse(ctx context.Context) (WorkspacesCreateOrUpdateResponse, error) { + respType := WorkspacesCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.Workspace) + if err != nil { + return WorkspacesCreateOrUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *workspacesCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *workspacesCreateOrUpdatePoller) pollUntilDone(ctx context.Context, freq time.Duration) (WorkspacesCreateOrUpdateResponse, error) { + respType := WorkspacesCreateOrUpdateResponse{} + resp, err := p.pt.PollUntilDone(ctx, freq, &respType.Workspace) + if err != nil { + return WorkspacesCreateOrUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// WorkspacesDeletePoller provides polling facilities until the operation reaches a terminal state. +type WorkspacesDeletePoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final WorkspacesDeleteResponse will be returned. + FinalResponse(ctx context.Context) (WorkspacesDeleteResponse, error) +} + +type workspacesDeletePoller struct { + pt *armcore.LROPoller +} + +func (p *workspacesDeletePoller) Done() bool { + return p.pt.Done() +} + +func (p *workspacesDeletePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *workspacesDeletePoller) FinalResponse(ctx context.Context) (WorkspacesDeleteResponse, error) { + respType := WorkspacesDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return WorkspacesDeleteResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *workspacesDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *workspacesDeletePoller) pollUntilDone(ctx context.Context, freq time.Duration) (WorkspacesDeleteResponse, error) { + respType := WorkspacesDeleteResponse{} + resp, err := p.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return WorkspacesDeleteResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} diff --git a/sdk/operationalinsights/armoperationalinsights/zz_generated_response_types.go b/sdk/operationalinsights/armoperationalinsights/zz_generated_response_types.go new file mode 100644 index 000000000000..09f21e5df7a9 --- /dev/null +++ b/sdk/operationalinsights/armoperationalinsights/zz_generated_response_types.go @@ -0,0 +1,690 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armoperationalinsights + +import ( + "context" + "net/http" + "time" +) + +// AvailableServiceTiersListByWorkspaceResponse contains the response from method AvailableServiceTiers.ListByWorkspace. +type AvailableServiceTiersListByWorkspaceResponse struct { + AvailableServiceTiersListByWorkspaceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AvailableServiceTiersListByWorkspaceResult contains the result from method AvailableServiceTiers.ListByWorkspace. +type AvailableServiceTiersListByWorkspaceResult struct { + // Array of AvailableServiceTier + AvailableServiceTierArray []*AvailableServiceTier +} + +// ClustersCreateOrUpdatePollerResponse contains the response from method Clusters.CreateOrUpdate. +type ClustersCreateOrUpdatePollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (ClustersCreateOrUpdateResponse, error) + + // Poller contains an initialized poller. + Poller ClustersCreateOrUpdatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ClustersCreateOrUpdateResponse contains the response from method Clusters.CreateOrUpdate. +type ClustersCreateOrUpdateResponse struct { + ClustersCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ClustersCreateOrUpdateResult contains the result from method Clusters.CreateOrUpdate. +type ClustersCreateOrUpdateResult struct { + Cluster +} + +// ClustersDeletePollerResponse contains the response from method Clusters.Delete. +type ClustersDeletePollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (ClustersDeleteResponse, error) + + // Poller contains an initialized poller. + Poller ClustersDeletePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ClustersDeleteResponse contains the response from method Clusters.Delete. +type ClustersDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ClustersGetResponse contains the response from method Clusters.Get. +type ClustersGetResponse struct { + ClustersGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ClustersGetResult contains the result from method Clusters.Get. +type ClustersGetResult struct { + Cluster +} + +// ClustersListByResourceGroupResponse contains the response from method Clusters.ListByResourceGroup. +type ClustersListByResourceGroupResponse struct { + ClustersListByResourceGroupResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ClustersListByResourceGroupResult contains the result from method Clusters.ListByResourceGroup. +type ClustersListByResourceGroupResult struct { + ClusterListResult +} + +// ClustersListResponse contains the response from method Clusters.List. +type ClustersListResponse struct { + ClustersListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ClustersListResult contains the result from method Clusters.List. +type ClustersListResult struct { + ClusterListResult +} + +// ClustersUpdateResponse contains the response from method Clusters.Update. +type ClustersUpdateResponse struct { + ClustersUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ClustersUpdateResult contains the result from method Clusters.Update. +type ClustersUpdateResult struct { + Cluster +} + +// DataExportsCreateOrUpdateResponse contains the response from method DataExports.CreateOrUpdate. +type DataExportsCreateOrUpdateResponse struct { + DataExportsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DataExportsCreateOrUpdateResult contains the result from method DataExports.CreateOrUpdate. +type DataExportsCreateOrUpdateResult struct { + DataExport +} + +// DataExportsDeleteResponse contains the response from method DataExports.Delete. +type DataExportsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DataExportsGetResponse contains the response from method DataExports.Get. +type DataExportsGetResponse struct { + DataExportsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DataExportsGetResult contains the result from method DataExports.Get. +type DataExportsGetResult struct { + DataExport +} + +// DataExportsListByWorkspaceResponse contains the response from method DataExports.ListByWorkspace. +type DataExportsListByWorkspaceResponse struct { + DataExportsListByWorkspaceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DataExportsListByWorkspaceResult contains the result from method DataExports.ListByWorkspace. +type DataExportsListByWorkspaceResult struct { + DataExportListResult +} + +// DataSourcesCreateOrUpdateResponse contains the response from method DataSources.CreateOrUpdate. +type DataSourcesCreateOrUpdateResponse struct { + DataSourcesCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DataSourcesCreateOrUpdateResult contains the result from method DataSources.CreateOrUpdate. +type DataSourcesCreateOrUpdateResult struct { + DataSource +} + +// DataSourcesDeleteResponse contains the response from method DataSources.Delete. +type DataSourcesDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DataSourcesGetResponse contains the response from method DataSources.Get. +type DataSourcesGetResponse struct { + DataSourcesGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DataSourcesGetResult contains the result from method DataSources.Get. +type DataSourcesGetResult struct { + DataSource +} + +// DataSourcesListByWorkspaceResponse contains the response from method DataSources.ListByWorkspace. +type DataSourcesListByWorkspaceResponse struct { + DataSourcesListByWorkspaceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DataSourcesListByWorkspaceResult contains the result from method DataSources.ListByWorkspace. +type DataSourcesListByWorkspaceResult struct { + DataSourceListResult +} + +// DeletedWorkspacesListByResourceGroupResponse contains the response from method DeletedWorkspaces.ListByResourceGroup. +type DeletedWorkspacesListByResourceGroupResponse struct { + DeletedWorkspacesListByResourceGroupResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DeletedWorkspacesListByResourceGroupResult contains the result from method DeletedWorkspaces.ListByResourceGroup. +type DeletedWorkspacesListByResourceGroupResult struct { + WorkspaceListResult +} + +// DeletedWorkspacesListResponse contains the response from method DeletedWorkspaces.List. +type DeletedWorkspacesListResponse struct { + DeletedWorkspacesListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DeletedWorkspacesListResult contains the result from method DeletedWorkspaces.List. +type DeletedWorkspacesListResult struct { + WorkspaceListResult +} + +// GatewaysDeleteResponse contains the response from method Gateways.Delete. +type GatewaysDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// IntelligencePacksDisableResponse contains the response from method IntelligencePacks.Disable. +type IntelligencePacksDisableResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// IntelligencePacksEnableResponse contains the response from method IntelligencePacks.Enable. +type IntelligencePacksEnableResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// IntelligencePacksListResponse contains the response from method IntelligencePacks.List. +type IntelligencePacksListResponse struct { + IntelligencePacksListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// IntelligencePacksListResult contains the result from method IntelligencePacks.List. +type IntelligencePacksListResult struct { + // Array of IntelligencePack + IntelligencePackArray []*IntelligencePack +} + +// LinkedServicesCreateOrUpdatePollerResponse contains the response from method LinkedServices.CreateOrUpdate. +type LinkedServicesCreateOrUpdatePollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (LinkedServicesCreateOrUpdateResponse, error) + + // Poller contains an initialized poller. + Poller LinkedServicesCreateOrUpdatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LinkedServicesCreateOrUpdateResponse contains the response from method LinkedServices.CreateOrUpdate. +type LinkedServicesCreateOrUpdateResponse struct { + LinkedServicesCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LinkedServicesCreateOrUpdateResult contains the result from method LinkedServices.CreateOrUpdate. +type LinkedServicesCreateOrUpdateResult struct { + LinkedService +} + +// LinkedServicesDeletePollerResponse contains the response from method LinkedServices.Delete. +type LinkedServicesDeletePollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (LinkedServicesDeleteResponse, error) + + // Poller contains an initialized poller. + Poller LinkedServicesDeletePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LinkedServicesDeleteResponse contains the response from method LinkedServices.Delete. +type LinkedServicesDeleteResponse struct { + LinkedServicesDeleteResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LinkedServicesDeleteResult contains the result from method LinkedServices.Delete. +type LinkedServicesDeleteResult struct { + LinkedService +} + +// LinkedServicesGetResponse contains the response from method LinkedServices.Get. +type LinkedServicesGetResponse struct { + LinkedServicesGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LinkedServicesGetResult contains the result from method LinkedServices.Get. +type LinkedServicesGetResult struct { + LinkedService +} + +// LinkedServicesListByWorkspaceResponse contains the response from method LinkedServices.ListByWorkspace. +type LinkedServicesListByWorkspaceResponse struct { + LinkedServicesListByWorkspaceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LinkedServicesListByWorkspaceResult contains the result from method LinkedServices.ListByWorkspace. +type LinkedServicesListByWorkspaceResult struct { + LinkedServiceListResult +} + +// LinkedStorageAccountsCreateOrUpdateResponse contains the response from method LinkedStorageAccounts.CreateOrUpdate. +type LinkedStorageAccountsCreateOrUpdateResponse struct { + LinkedStorageAccountsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LinkedStorageAccountsCreateOrUpdateResult contains the result from method LinkedStorageAccounts.CreateOrUpdate. +type LinkedStorageAccountsCreateOrUpdateResult struct { + LinkedStorageAccountsResource +} + +// LinkedStorageAccountsDeleteResponse contains the response from method LinkedStorageAccounts.Delete. +type LinkedStorageAccountsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LinkedStorageAccountsGetResponse contains the response from method LinkedStorageAccounts.Get. +type LinkedStorageAccountsGetResponse struct { + LinkedStorageAccountsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LinkedStorageAccountsGetResult contains the result from method LinkedStorageAccounts.Get. +type LinkedStorageAccountsGetResult struct { + LinkedStorageAccountsResource +} + +// LinkedStorageAccountsListByWorkspaceResponse contains the response from method LinkedStorageAccounts.ListByWorkspace. +type LinkedStorageAccountsListByWorkspaceResponse struct { + LinkedStorageAccountsListByWorkspaceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LinkedStorageAccountsListByWorkspaceResult contains the result from method LinkedStorageAccounts.ListByWorkspace. +type LinkedStorageAccountsListByWorkspaceResult struct { + LinkedStorageAccountsListResult +} + +// ManagementGroupsListResponse contains the response from method ManagementGroups.List. +type ManagementGroupsListResponse struct { + ManagementGroupsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ManagementGroupsListResult contains the result from method ManagementGroups.List. +type ManagementGroupsListResult struct { + WorkspaceListManagementGroupsResult +} + +// OperationStatusesGetResponse contains the response from method OperationStatuses.Get. +type OperationStatusesGetResponse struct { + OperationStatusesGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// OperationStatusesGetResult contains the result from method OperationStatuses.Get. +type OperationStatusesGetResult struct { + OperationStatus +} + +// OperationsListResponse contains the response from method Operations.List. +type OperationsListResponse struct { + OperationsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// OperationsListResult contains the result from method Operations.List. +type OperationsListResult struct { + OperationListResult +} + +// SavedSearchesCreateOrUpdateResponse contains the response from method SavedSearches.CreateOrUpdate. +type SavedSearchesCreateOrUpdateResponse struct { + SavedSearchesCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SavedSearchesCreateOrUpdateResult contains the result from method SavedSearches.CreateOrUpdate. +type SavedSearchesCreateOrUpdateResult struct { + SavedSearch +} + +// SavedSearchesDeleteResponse contains the response from method SavedSearches.Delete. +type SavedSearchesDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SavedSearchesGetResponse contains the response from method SavedSearches.Get. +type SavedSearchesGetResponse struct { + SavedSearchesGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SavedSearchesGetResult contains the result from method SavedSearches.Get. +type SavedSearchesGetResult struct { + SavedSearch +} + +// SavedSearchesListByWorkspaceResponse contains the response from method SavedSearches.ListByWorkspace. +type SavedSearchesListByWorkspaceResponse struct { + SavedSearchesListByWorkspaceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SavedSearchesListByWorkspaceResult contains the result from method SavedSearches.ListByWorkspace. +type SavedSearchesListByWorkspaceResult struct { + SavedSearchesListResult +} + +// SchemaGetResponse contains the response from method Schema.Get. +type SchemaGetResponse struct { + SchemaGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SchemaGetResult contains the result from method Schema.Get. +type SchemaGetResult struct { + SearchGetSchemaResponse +} + +// SharedKeysGetSharedKeysResponse contains the response from method SharedKeys.GetSharedKeys. +type SharedKeysGetSharedKeysResponse struct { + SharedKeysGetSharedKeysResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SharedKeysGetSharedKeysResult contains the result from method SharedKeys.GetSharedKeys. +type SharedKeysGetSharedKeysResult struct { + SharedKeys +} + +// SharedKeysRegenerateResponse contains the response from method SharedKeys.Regenerate. +type SharedKeysRegenerateResponse struct { + SharedKeysRegenerateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SharedKeysRegenerateResult contains the result from method SharedKeys.Regenerate. +type SharedKeysRegenerateResult struct { + SharedKeys +} + +// StorageInsightConfigsCreateOrUpdateResponse contains the response from method StorageInsightConfigs.CreateOrUpdate. +type StorageInsightConfigsCreateOrUpdateResponse struct { + StorageInsightConfigsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// StorageInsightConfigsCreateOrUpdateResult contains the result from method StorageInsightConfigs.CreateOrUpdate. +type StorageInsightConfigsCreateOrUpdateResult struct { + StorageInsight +} + +// StorageInsightConfigsDeleteResponse contains the response from method StorageInsightConfigs.Delete. +type StorageInsightConfigsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// StorageInsightConfigsGetResponse contains the response from method StorageInsightConfigs.Get. +type StorageInsightConfigsGetResponse struct { + StorageInsightConfigsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// StorageInsightConfigsGetResult contains the result from method StorageInsightConfigs.Get. +type StorageInsightConfigsGetResult struct { + StorageInsight +} + +// StorageInsightConfigsListByWorkspaceResponse contains the response from method StorageInsightConfigs.ListByWorkspace. +type StorageInsightConfigsListByWorkspaceResponse struct { + StorageInsightConfigsListByWorkspaceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// StorageInsightConfigsListByWorkspaceResult contains the result from method StorageInsightConfigs.ListByWorkspace. +type StorageInsightConfigsListByWorkspaceResult struct { + StorageInsightListResult +} + +// TablesGetResponse contains the response from method Tables.Get. +type TablesGetResponse struct { + TablesGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TablesGetResult contains the result from method Tables.Get. +type TablesGetResult struct { + Table +} + +// TablesListByWorkspaceResponse contains the response from method Tables.ListByWorkspace. +type TablesListByWorkspaceResponse struct { + TablesListByWorkspaceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TablesListByWorkspaceResult contains the result from method Tables.ListByWorkspace. +type TablesListByWorkspaceResult struct { + TablesListResult +} + +// TablesUpdateResponse contains the response from method Tables.Update. +type TablesUpdateResponse struct { + TablesUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TablesUpdateResult contains the result from method Tables.Update. +type TablesUpdateResult struct { + Table +} + +// UsagesListResponse contains the response from method Usages.List. +type UsagesListResponse struct { + UsagesListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// UsagesListResult contains the result from method Usages.List. +type UsagesListResult struct { + WorkspaceListUsagesResult +} + +// WorkspacePurgeGetPurgeStatusResponse contains the response from method WorkspacePurge.GetPurgeStatus. +type WorkspacePurgeGetPurgeStatusResponse struct { + WorkspacePurgeGetPurgeStatusResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkspacePurgeGetPurgeStatusResult contains the result from method WorkspacePurge.GetPurgeStatus. +type WorkspacePurgeGetPurgeStatusResult struct { + WorkspacePurgeStatusResponse +} + +// WorkspacePurgePurgeResponse contains the response from method WorkspacePurge.Purge. +type WorkspacePurgePurgeResponse struct { + WorkspacePurgePurgeResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkspacePurgePurgeResult contains the result from method WorkspacePurge.Purge. +type WorkspacePurgePurgeResult struct { + WorkspacePurgeResponse + // XMSStatusLocation contains the information returned from the x-ms-status-location header response. + XMSStatusLocation *string +} + +// WorkspacesCreateOrUpdatePollerResponse contains the response from method Workspaces.CreateOrUpdate. +type WorkspacesCreateOrUpdatePollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (WorkspacesCreateOrUpdateResponse, error) + + // Poller contains an initialized poller. + Poller WorkspacesCreateOrUpdatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkspacesCreateOrUpdateResponse contains the response from method Workspaces.CreateOrUpdate. +type WorkspacesCreateOrUpdateResponse struct { + WorkspacesCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkspacesCreateOrUpdateResult contains the result from method Workspaces.CreateOrUpdate. +type WorkspacesCreateOrUpdateResult struct { + Workspace +} + +// WorkspacesDeletePollerResponse contains the response from method Workspaces.Delete. +type WorkspacesDeletePollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (WorkspacesDeleteResponse, error) + + // Poller contains an initialized poller. + Poller WorkspacesDeletePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkspacesDeleteResponse contains the response from method Workspaces.Delete. +type WorkspacesDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkspacesGetResponse contains the response from method Workspaces.Get. +type WorkspacesGetResponse struct { + WorkspacesGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkspacesGetResult contains the result from method Workspaces.Get. +type WorkspacesGetResult struct { + Workspace +} + +// WorkspacesListByResourceGroupResponse contains the response from method Workspaces.ListByResourceGroup. +type WorkspacesListByResourceGroupResponse struct { + WorkspacesListByResourceGroupResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkspacesListByResourceGroupResult contains the result from method Workspaces.ListByResourceGroup. +type WorkspacesListByResourceGroupResult struct { + WorkspaceListResult +} + +// WorkspacesListResponse contains the response from method Workspaces.List. +type WorkspacesListResponse struct { + WorkspacesListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkspacesListResult contains the result from method Workspaces.List. +type WorkspacesListResult struct { + WorkspaceListResult +} + +// WorkspacesUpdateResponse contains the response from method Workspaces.Update. +type WorkspacesUpdateResponse struct { + WorkspacesUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WorkspacesUpdateResult contains the result from method Workspaces.Update. +type WorkspacesUpdateResult struct { + Workspace +} diff --git a/sdk/operationalinsights/armoperationalinsights/zz_generated_savedsearches_client.go b/sdk/operationalinsights/armoperationalinsights/zz_generated_savedsearches_client.go new file mode 100644 index 000000000000..f5583a319908 --- /dev/null +++ b/sdk/operationalinsights/armoperationalinsights/zz_generated_savedsearches_client.go @@ -0,0 +1,292 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armoperationalinsights + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// SavedSearchesClient contains the methods for the SavedSearches group. +// Don't use this type directly, use NewSavedSearchesClient() instead. +type SavedSearchesClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewSavedSearchesClient creates a new instance of SavedSearchesClient with the specified values. +func NewSavedSearchesClient(con *armcore.Connection, subscriptionID string) *SavedSearchesClient { + return &SavedSearchesClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Creates or updates a saved search for a given workspace. +// If the operation fails it returns a generic error. +func (client *SavedSearchesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, workspaceName string, savedSearchID string, parameters SavedSearch, options *SavedSearchesCreateOrUpdateOptions) (SavedSearchesCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, workspaceName, savedSearchID, parameters, options) + if err != nil { + return SavedSearchesCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return SavedSearchesCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return SavedSearchesCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *SavedSearchesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, savedSearchID string, parameters SavedSearch, options *SavedSearchesCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/savedSearches/{savedSearchId}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if savedSearchID == "" { + return nil, errors.New("parameter savedSearchID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{savedSearchId}", url.PathEscape(savedSearchID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-08-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *SavedSearchesClient) createOrUpdateHandleResponse(resp *azcore.Response) (SavedSearchesCreateOrUpdateResponse, error) { + result := SavedSearchesCreateOrUpdateResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.SavedSearch); err != nil { + return SavedSearchesCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *SavedSearchesClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// Delete - Deletes the specified saved search in a given workspace. +// If the operation fails it returns a generic error. +func (client *SavedSearchesClient) Delete(ctx context.Context, resourceGroupName string, workspaceName string, savedSearchID string, options *SavedSearchesDeleteOptions) (SavedSearchesDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, workspaceName, savedSearchID, options) + if err != nil { + return SavedSearchesDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return SavedSearchesDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return SavedSearchesDeleteResponse{}, client.deleteHandleError(resp) + } + return SavedSearchesDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *SavedSearchesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, savedSearchID string, options *SavedSearchesDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/savedSearches/{savedSearchId}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if savedSearchID == "" { + return nil, errors.New("parameter savedSearchID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{savedSearchId}", url.PathEscape(savedSearchID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-08-01") + req.URL.RawQuery = reqQP.Encode() + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *SavedSearchesClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// Get - Gets the specified saved search for a given workspace. +// If the operation fails it returns a generic error. +func (client *SavedSearchesClient) Get(ctx context.Context, resourceGroupName string, workspaceName string, savedSearchID string, options *SavedSearchesGetOptions) (SavedSearchesGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, workspaceName, savedSearchID, options) + if err != nil { + return SavedSearchesGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return SavedSearchesGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return SavedSearchesGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *SavedSearchesClient) getCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, savedSearchID string, options *SavedSearchesGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/savedSearches/{savedSearchId}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if savedSearchID == "" { + return nil, errors.New("parameter savedSearchID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{savedSearchId}", url.PathEscape(savedSearchID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-08-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *SavedSearchesClient) getHandleResponse(resp *azcore.Response) (SavedSearchesGetResponse, error) { + result := SavedSearchesGetResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.SavedSearch); err != nil { + return SavedSearchesGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *SavedSearchesClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// ListByWorkspace - Gets the saved searches for a given Log Analytics Workspace +// If the operation fails it returns a generic error. +func (client *SavedSearchesClient) ListByWorkspace(ctx context.Context, resourceGroupName string, workspaceName string, options *SavedSearchesListByWorkspaceOptions) (SavedSearchesListByWorkspaceResponse, error) { + req, err := client.listByWorkspaceCreateRequest(ctx, resourceGroupName, workspaceName, options) + if err != nil { + return SavedSearchesListByWorkspaceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return SavedSearchesListByWorkspaceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return SavedSearchesListByWorkspaceResponse{}, client.listByWorkspaceHandleError(resp) + } + return client.listByWorkspaceHandleResponse(resp) +} + +// listByWorkspaceCreateRequest creates the ListByWorkspace request. +func (client *SavedSearchesClient) listByWorkspaceCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, options *SavedSearchesListByWorkspaceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/savedSearches" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-08-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByWorkspaceHandleResponse handles the ListByWorkspace response. +func (client *SavedSearchesClient) listByWorkspaceHandleResponse(resp *azcore.Response) (SavedSearchesListByWorkspaceResponse, error) { + result := SavedSearchesListByWorkspaceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.SavedSearchesListResult); err != nil { + return SavedSearchesListByWorkspaceResponse{}, err + } + return result, nil +} + +// listByWorkspaceHandleError handles the ListByWorkspace error response. +func (client *SavedSearchesClient) listByWorkspaceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} diff --git a/sdk/operationalinsights/armoperationalinsights/zz_generated_schema_client.go b/sdk/operationalinsights/armoperationalinsights/zz_generated_schema_client.go new file mode 100644 index 000000000000..b28d5dfab38b --- /dev/null +++ b/sdk/operationalinsights/armoperationalinsights/zz_generated_schema_client.go @@ -0,0 +1,95 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armoperationalinsights + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// SchemaClient contains the methods for the Schema group. +// Don't use this type directly, use NewSchemaClient() instead. +type SchemaClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewSchemaClient creates a new instance of SchemaClient with the specified values. +func NewSchemaClient(con *armcore.Connection, subscriptionID string) *SchemaClient { + return &SchemaClient{con: con, subscriptionID: subscriptionID} +} + +// Get - Gets the schema for a given workspace. +// If the operation fails it returns a generic error. +func (client *SchemaClient) Get(ctx context.Context, resourceGroupName string, workspaceName string, options *SchemaGetOptions) (SchemaGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, workspaceName, options) + if err != nil { + return SchemaGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return SchemaGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return SchemaGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *SchemaClient) getCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, options *SchemaGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/schema" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-08-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *SchemaClient) getHandleResponse(resp *azcore.Response) (SchemaGetResponse, error) { + result := SchemaGetResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.SearchGetSchemaResponse); err != nil { + return SchemaGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *SchemaClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} diff --git a/sdk/operationalinsights/armoperationalinsights/zz_generated_sharedkeys_client.go b/sdk/operationalinsights/armoperationalinsights/zz_generated_sharedkeys_client.go new file mode 100644 index 000000000000..f5728a23b9b9 --- /dev/null +++ b/sdk/operationalinsights/armoperationalinsights/zz_generated_sharedkeys_client.go @@ -0,0 +1,160 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armoperationalinsights + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// SharedKeysClient contains the methods for the SharedKeys group. +// Don't use this type directly, use NewSharedKeysClient() instead. +type SharedKeysClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewSharedKeysClient creates a new instance of SharedKeysClient with the specified values. +func NewSharedKeysClient(con *armcore.Connection, subscriptionID string) *SharedKeysClient { + return &SharedKeysClient{con: con, subscriptionID: subscriptionID} +} + +// GetSharedKeys - Gets the shared keys for a workspace. +// If the operation fails it returns a generic error. +func (client *SharedKeysClient) GetSharedKeys(ctx context.Context, resourceGroupName string, workspaceName string, options *SharedKeysGetSharedKeysOptions) (SharedKeysGetSharedKeysResponse, error) { + req, err := client.getSharedKeysCreateRequest(ctx, resourceGroupName, workspaceName, options) + if err != nil { + return SharedKeysGetSharedKeysResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return SharedKeysGetSharedKeysResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return SharedKeysGetSharedKeysResponse{}, client.getSharedKeysHandleError(resp) + } + return client.getSharedKeysHandleResponse(resp) +} + +// getSharedKeysCreateRequest creates the GetSharedKeys request. +func (client *SharedKeysClient) getSharedKeysCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, options *SharedKeysGetSharedKeysOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/sharedKeys" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-08-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getSharedKeysHandleResponse handles the GetSharedKeys response. +func (client *SharedKeysClient) getSharedKeysHandleResponse(resp *azcore.Response) (SharedKeysGetSharedKeysResponse, error) { + result := SharedKeysGetSharedKeysResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.SharedKeys); err != nil { + return SharedKeysGetSharedKeysResponse{}, err + } + return result, nil +} + +// getSharedKeysHandleError handles the GetSharedKeys error response. +func (client *SharedKeysClient) getSharedKeysHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// Regenerate - Regenerates the shared keys for a Log Analytics Workspace. These keys are used to connect Microsoft Operational Insights agents to the workspace. +// If the operation fails it returns a generic error. +func (client *SharedKeysClient) Regenerate(ctx context.Context, resourceGroupName string, workspaceName string, options *SharedKeysRegenerateOptions) (SharedKeysRegenerateResponse, error) { + req, err := client.regenerateCreateRequest(ctx, resourceGroupName, workspaceName, options) + if err != nil { + return SharedKeysRegenerateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return SharedKeysRegenerateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return SharedKeysRegenerateResponse{}, client.regenerateHandleError(resp) + } + return client.regenerateHandleResponse(resp) +} + +// regenerateCreateRequest creates the Regenerate request. +func (client *SharedKeysClient) regenerateCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, options *SharedKeysRegenerateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/regenerateSharedKey" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-08-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// regenerateHandleResponse handles the Regenerate response. +func (client *SharedKeysClient) regenerateHandleResponse(resp *azcore.Response) (SharedKeysRegenerateResponse, error) { + result := SharedKeysRegenerateResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.SharedKeys); err != nil { + return SharedKeysRegenerateResponse{}, err + } + return result, nil +} + +// regenerateHandleError handles the Regenerate error response. +func (client *SharedKeysClient) regenerateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} diff --git a/sdk/operationalinsights/armoperationalinsights/zz_generated_storageinsightconfigs_client.go b/sdk/operationalinsights/armoperationalinsights/zz_generated_storageinsightconfigs_client.go new file mode 100644 index 000000000000..bc2dfeb2f68d --- /dev/null +++ b/sdk/operationalinsights/armoperationalinsights/zz_generated_storageinsightconfigs_client.go @@ -0,0 +1,289 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armoperationalinsights + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// StorageInsightConfigsClient contains the methods for the StorageInsightConfigs group. +// Don't use this type directly, use NewStorageInsightConfigsClient() instead. +type StorageInsightConfigsClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewStorageInsightConfigsClient creates a new instance of StorageInsightConfigsClient with the specified values. +func NewStorageInsightConfigsClient(con *armcore.Connection, subscriptionID string) *StorageInsightConfigsClient { + return &StorageInsightConfigsClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Create or update a storage insight. +// If the operation fails it returns a generic error. +func (client *StorageInsightConfigsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, workspaceName string, storageInsightName string, parameters StorageInsight, options *StorageInsightConfigsCreateOrUpdateOptions) (StorageInsightConfigsCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, workspaceName, storageInsightName, parameters, options) + if err != nil { + return StorageInsightConfigsCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return StorageInsightConfigsCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return StorageInsightConfigsCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *StorageInsightConfigsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, storageInsightName string, parameters StorageInsight, options *StorageInsightConfigsCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/storageInsightConfigs/{storageInsightName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if storageInsightName == "" { + return nil, errors.New("parameter storageInsightName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageInsightName}", url.PathEscape(storageInsightName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-08-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *StorageInsightConfigsClient) createOrUpdateHandleResponse(resp *azcore.Response) (StorageInsightConfigsCreateOrUpdateResponse, error) { + result := StorageInsightConfigsCreateOrUpdateResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.StorageInsight); err != nil { + return StorageInsightConfigsCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *StorageInsightConfigsClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// Delete - Deletes a storageInsightsConfigs resource +// If the operation fails it returns a generic error. +func (client *StorageInsightConfigsClient) Delete(ctx context.Context, resourceGroupName string, workspaceName string, storageInsightName string, options *StorageInsightConfigsDeleteOptions) (StorageInsightConfigsDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, workspaceName, storageInsightName, options) + if err != nil { + return StorageInsightConfigsDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return StorageInsightConfigsDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return StorageInsightConfigsDeleteResponse{}, client.deleteHandleError(resp) + } + return StorageInsightConfigsDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *StorageInsightConfigsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, storageInsightName string, options *StorageInsightConfigsDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/storageInsightConfigs/{storageInsightName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if storageInsightName == "" { + return nil, errors.New("parameter storageInsightName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageInsightName}", url.PathEscape(storageInsightName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-08-01") + req.URL.RawQuery = reqQP.Encode() + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *StorageInsightConfigsClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// Get - Gets a storage insight instance. +// If the operation fails it returns a generic error. +func (client *StorageInsightConfigsClient) Get(ctx context.Context, resourceGroupName string, workspaceName string, storageInsightName string, options *StorageInsightConfigsGetOptions) (StorageInsightConfigsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, workspaceName, storageInsightName, options) + if err != nil { + return StorageInsightConfigsGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return StorageInsightConfigsGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return StorageInsightConfigsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *StorageInsightConfigsClient) getCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, storageInsightName string, options *StorageInsightConfigsGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/storageInsightConfigs/{storageInsightName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if storageInsightName == "" { + return nil, errors.New("parameter storageInsightName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageInsightName}", url.PathEscape(storageInsightName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-08-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *StorageInsightConfigsClient) getHandleResponse(resp *azcore.Response) (StorageInsightConfigsGetResponse, error) { + result := StorageInsightConfigsGetResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.StorageInsight); err != nil { + return StorageInsightConfigsGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *StorageInsightConfigsClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// ListByWorkspace - Lists the storage insight instances within a workspace +// If the operation fails it returns a generic error. +func (client *StorageInsightConfigsClient) ListByWorkspace(resourceGroupName string, workspaceName string, options *StorageInsightConfigsListByWorkspaceOptions) StorageInsightConfigsListByWorkspacePager { + return &storageInsightConfigsListByWorkspacePager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByWorkspaceCreateRequest(ctx, resourceGroupName, workspaceName, options) + }, + advancer: func(ctx context.Context, resp StorageInsightConfigsListByWorkspaceResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.StorageInsightListResult.OdataNextLink) + }, + } +} + +// listByWorkspaceCreateRequest creates the ListByWorkspace request. +func (client *StorageInsightConfigsClient) listByWorkspaceCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, options *StorageInsightConfigsListByWorkspaceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/storageInsightConfigs" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-08-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByWorkspaceHandleResponse handles the ListByWorkspace response. +func (client *StorageInsightConfigsClient) listByWorkspaceHandleResponse(resp *azcore.Response) (StorageInsightConfigsListByWorkspaceResponse, error) { + result := StorageInsightConfigsListByWorkspaceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.StorageInsightListResult); err != nil { + return StorageInsightConfigsListByWorkspaceResponse{}, err + } + return result, nil +} + +// listByWorkspaceHandleError handles the ListByWorkspace error response. +func (client *StorageInsightConfigsClient) listByWorkspaceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} diff --git a/sdk/operationalinsights/armoperationalinsights/zz_generated_tables_client.go b/sdk/operationalinsights/armoperationalinsights/zz_generated_tables_client.go new file mode 100644 index 000000000000..40dcac854abc --- /dev/null +++ b/sdk/operationalinsights/armoperationalinsights/zz_generated_tables_client.go @@ -0,0 +1,237 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armoperationalinsights + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// TablesClient contains the methods for the Tables group. +// Don't use this type directly, use NewTablesClient() instead. +type TablesClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewTablesClient creates a new instance of TablesClient with the specified values. +func NewTablesClient(con *armcore.Connection, subscriptionID string) *TablesClient { + return &TablesClient{con: con, subscriptionID: subscriptionID} +} + +// Get - Gets a Log Analytics workspace table. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TablesClient) Get(ctx context.Context, resourceGroupName string, workspaceName string, tableName string, options *TablesGetOptions) (TablesGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, workspaceName, tableName, options) + if err != nil { + return TablesGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return TablesGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return TablesGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *TablesClient) getCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, tableName string, options *TablesGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if tableName == "" { + return nil, errors.New("parameter tableName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tableName}", url.PathEscape(tableName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-08-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *TablesClient) getHandleResponse(resp *azcore.Response) (TablesGetResponse, error) { + result := TablesGetResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.Table); err != nil { + return TablesGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *TablesClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByWorkspace - Gets all the tables for the specified Log Analytics workspace. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TablesClient) ListByWorkspace(ctx context.Context, resourceGroupName string, workspaceName string, options *TablesListByWorkspaceOptions) (TablesListByWorkspaceResponse, error) { + req, err := client.listByWorkspaceCreateRequest(ctx, resourceGroupName, workspaceName, options) + if err != nil { + return TablesListByWorkspaceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return TablesListByWorkspaceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return TablesListByWorkspaceResponse{}, client.listByWorkspaceHandleError(resp) + } + return client.listByWorkspaceHandleResponse(resp) +} + +// listByWorkspaceCreateRequest creates the ListByWorkspace request. +func (client *TablesClient) listByWorkspaceCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, options *TablesListByWorkspaceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-08-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByWorkspaceHandleResponse handles the ListByWorkspace response. +func (client *TablesClient) listByWorkspaceHandleResponse(resp *azcore.Response) (TablesListByWorkspaceResponse, error) { + result := TablesListByWorkspaceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.TablesListResult); err != nil { + return TablesListByWorkspaceResponse{}, err + } + return result, nil +} + +// listByWorkspaceHandleError handles the ListByWorkspace error response. +func (client *TablesClient) listByWorkspaceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Update - Updates a Log Analytics workspace table properties. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TablesClient) Update(ctx context.Context, resourceGroupName string, workspaceName string, tableName string, parameters Table, options *TablesUpdateOptions) (TablesUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, workspaceName, tableName, parameters, options) + if err != nil { + return TablesUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return TablesUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return TablesUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *TablesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, tableName string, parameters Table, options *TablesUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if tableName == "" { + return nil, errors.New("parameter tableName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tableName}", url.PathEscape(tableName)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-08-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// updateHandleResponse handles the Update response. +func (client *TablesClient) updateHandleResponse(resp *azcore.Response) (TablesUpdateResponse, error) { + result := TablesUpdateResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.Table); err != nil { + return TablesUpdateResponse{}, err + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *TablesClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/operationalinsights/armoperationalinsights/zz_generated_time_rfc3339.go b/sdk/operationalinsights/armoperationalinsights/zz_generated_time_rfc3339.go new file mode 100644 index 000000000000..aad842b2f6a3 --- /dev/null +++ b/sdk/operationalinsights/armoperationalinsights/zz_generated_time_rfc3339.go @@ -0,0 +1,57 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armoperationalinsights + +import ( + "regexp" + "strings" + "time" +) + +const ( + utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` + utcLayout = "2006-01-02T15:04:05.999999999" + rfc3339JSON = `"` + time.RFC3339Nano + `"` +) + +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) + +type timeRFC3339 time.Time + +func (t timeRFC3339) MarshalJSON() (json []byte, err error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t timeRFC3339) MarshalText() (text []byte, err error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *timeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcLayoutJSON + if tzOffsetRegex.Match(data) { + layout = rfc3339JSON + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { + layout := utcLayout + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = timeRFC3339(p) + return err +} diff --git a/sdk/operationalinsights/armoperationalinsights/zz_generated_usages_client.go b/sdk/operationalinsights/armoperationalinsights/zz_generated_usages_client.go new file mode 100644 index 000000000000..1158af51ee7c --- /dev/null +++ b/sdk/operationalinsights/armoperationalinsights/zz_generated_usages_client.go @@ -0,0 +1,95 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armoperationalinsights + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// UsagesClient contains the methods for the Usages group. +// Don't use this type directly, use NewUsagesClient() instead. +type UsagesClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewUsagesClient creates a new instance of UsagesClient with the specified values. +func NewUsagesClient(con *armcore.Connection, subscriptionID string) *UsagesClient { + return &UsagesClient{con: con, subscriptionID: subscriptionID} +} + +// List - Gets a list of usage metrics for a workspace. +// If the operation fails it returns a generic error. +func (client *UsagesClient) List(ctx context.Context, resourceGroupName string, workspaceName string, options *UsagesListOptions) (UsagesListResponse, error) { + req, err := client.listCreateRequest(ctx, resourceGroupName, workspaceName, options) + if err != nil { + return UsagesListResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return UsagesListResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return UsagesListResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *UsagesClient) listCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, options *UsagesListOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/usages" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-08-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *UsagesClient) listHandleResponse(resp *azcore.Response) (UsagesListResponse, error) { + result := UsagesListResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.WorkspaceListUsagesResult); err != nil { + return UsagesListResponse{}, err + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *UsagesClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} diff --git a/sdk/operationalinsights/armoperationalinsights/zz_generated_workspacepurge_client.go b/sdk/operationalinsights/armoperationalinsights/zz_generated_workspacepurge_client.go new file mode 100644 index 000000000000..cfa6648537fc --- /dev/null +++ b/sdk/operationalinsights/armoperationalinsights/zz_generated_workspacepurge_client.go @@ -0,0 +1,171 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armoperationalinsights + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// WorkspacePurgeClient contains the methods for the WorkspacePurge group. +// Don't use this type directly, use NewWorkspacePurgeClient() instead. +type WorkspacePurgeClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewWorkspacePurgeClient creates a new instance of WorkspacePurgeClient with the specified values. +func NewWorkspacePurgeClient(con *armcore.Connection, subscriptionID string) *WorkspacePurgeClient { + return &WorkspacePurgeClient{con: con, subscriptionID: subscriptionID} +} + +// GetPurgeStatus - Gets status of an ongoing purge operation. +// If the operation fails it returns a generic error. +func (client *WorkspacePurgeClient) GetPurgeStatus(ctx context.Context, resourceGroupName string, workspaceName string, purgeID string, options *WorkspacePurgeGetPurgeStatusOptions) (WorkspacePurgeGetPurgeStatusResponse, error) { + req, err := client.getPurgeStatusCreateRequest(ctx, resourceGroupName, workspaceName, purgeID, options) + if err != nil { + return WorkspacePurgeGetPurgeStatusResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return WorkspacePurgeGetPurgeStatusResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return WorkspacePurgeGetPurgeStatusResponse{}, client.getPurgeStatusHandleError(resp) + } + return client.getPurgeStatusHandleResponse(resp) +} + +// getPurgeStatusCreateRequest creates the GetPurgeStatus request. +func (client *WorkspacePurgeClient) getPurgeStatusCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, purgeID string, options *WorkspacePurgeGetPurgeStatusOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/operations/{purgeId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if purgeID == "" { + return nil, errors.New("parameter purgeID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{purgeId}", url.PathEscape(purgeID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-08-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getPurgeStatusHandleResponse handles the GetPurgeStatus response. +func (client *WorkspacePurgeClient) getPurgeStatusHandleResponse(resp *azcore.Response) (WorkspacePurgeGetPurgeStatusResponse, error) { + result := WorkspacePurgeGetPurgeStatusResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.WorkspacePurgeStatusResponse); err != nil { + return WorkspacePurgeGetPurgeStatusResponse{}, err + } + return result, nil +} + +// getPurgeStatusHandleError handles the GetPurgeStatus error response. +func (client *WorkspacePurgeClient) getPurgeStatusHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// Purge - Purges data in an Log Analytics workspace by a set of user-defined filters. +// In order to manage system resources, purge requests are throttled at 50 requests per hour. You should batch the execution of purge requests by sending +// a single command whose predicate includes all +// user identities that require purging. Use the in operator to specify multiple identities. You should run the query prior to using for a purge request +// to verify that the results are expected. +// If the operation fails it returns a generic error. +func (client *WorkspacePurgeClient) Purge(ctx context.Context, resourceGroupName string, workspaceName string, body WorkspacePurgeBody, options *WorkspacePurgePurgeOptions) (WorkspacePurgePurgeResponse, error) { + req, err := client.purgeCreateRequest(ctx, resourceGroupName, workspaceName, body, options) + if err != nil { + return WorkspacePurgePurgeResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return WorkspacePurgePurgeResponse{}, err + } + if !resp.HasStatusCode(http.StatusAccepted) { + return WorkspacePurgePurgeResponse{}, client.purgeHandleError(resp) + } + return client.purgeHandleResponse(resp) +} + +// purgeCreateRequest creates the Purge request. +func (client *WorkspacePurgeClient) purgeCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, body WorkspacePurgeBody, options *WorkspacePurgePurgeOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/purge" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-08-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(body) +} + +// purgeHandleResponse handles the Purge response. +func (client *WorkspacePurgeClient) purgeHandleResponse(resp *azcore.Response) (WorkspacePurgePurgeResponse, error) { + result := WorkspacePurgePurgeResponse{RawResponse: resp.Response} + if val := resp.Header.Get("x-ms-status-location"); val != "" { + result.XMSStatusLocation = &val + } + if err := resp.UnmarshalAsJSON(&result.WorkspacePurgeResponse); err != nil { + return WorkspacePurgePurgeResponse{}, err + } + return result, nil +} + +// purgeHandleError handles the Purge error response. +func (client *WorkspacePurgeClient) purgeHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} diff --git a/sdk/operationalinsights/armoperationalinsights/zz_generated_workspaces_client.go b/sdk/operationalinsights/armoperationalinsights/zz_generated_workspaces_client.go new file mode 100644 index 000000000000..633ea93e6b8e --- /dev/null +++ b/sdk/operationalinsights/armoperationalinsights/zz_generated_workspaces_client.go @@ -0,0 +1,502 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armoperationalinsights + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" + "time" +) + +// WorkspacesClient contains the methods for the Workspaces group. +// Don't use this type directly, use NewWorkspacesClient() instead. +type WorkspacesClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewWorkspacesClient creates a new instance of WorkspacesClient with the specified values. +func NewWorkspacesClient(con *armcore.Connection, subscriptionID string) *WorkspacesClient { + return &WorkspacesClient{con: con, subscriptionID: subscriptionID} +} + +// BeginCreateOrUpdate - Create or update a workspace. +// If the operation fails it returns the *ErrorResponse error type. +func (client *WorkspacesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, workspaceName string, parameters Workspace, options *WorkspacesBeginCreateOrUpdateOptions) (WorkspacesCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, workspaceName, parameters, options) + if err != nil { + return WorkspacesCreateOrUpdatePollerResponse{}, err + } + result := WorkspacesCreateOrUpdatePollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("WorkspacesClient.CreateOrUpdate", "", resp, client.con.Pipeline(), client.createOrUpdateHandleError) + if err != nil { + return WorkspacesCreateOrUpdatePollerResponse{}, err + } + poller := &workspacesCreateOrUpdatePoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (WorkspacesCreateOrUpdateResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeCreateOrUpdate creates a new WorkspacesCreateOrUpdatePoller from the specified resume token. +// token - The value must come from a previous call to WorkspacesCreateOrUpdatePoller.ResumeToken(). +func (client *WorkspacesClient) ResumeCreateOrUpdate(ctx context.Context, token string) (WorkspacesCreateOrUpdatePollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("WorkspacesClient.CreateOrUpdate", token, client.con.Pipeline(), client.createOrUpdateHandleError) + if err != nil { + return WorkspacesCreateOrUpdatePollerResponse{}, err + } + poller := &workspacesCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return WorkspacesCreateOrUpdatePollerResponse{}, err + } + result := WorkspacesCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (WorkspacesCreateOrUpdateResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// CreateOrUpdate - Create or update a workspace. +// If the operation fails it returns the *ErrorResponse error type. +func (client *WorkspacesClient) createOrUpdate(ctx context.Context, resourceGroupName string, workspaceName string, parameters Workspace, options *WorkspacesBeginCreateOrUpdateOptions) (*azcore.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, workspaceName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted) { + return nil, client.createOrUpdateHandleError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *WorkspacesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, parameters Workspace, options *WorkspacesBeginCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-10-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *WorkspacesClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// BeginDelete - Deletes a workspace resource. To recover the workspace, create it again with the same name, in the same subscription, resource group and +// location. The name is kept for 14 days and cannot be used for +// another workspace. To remove the workspace completely and release the name, use the force flag. +// If the operation fails it returns the *ErrorResponse error type. +func (client *WorkspacesClient) BeginDelete(ctx context.Context, resourceGroupName string, workspaceName string, options *WorkspacesBeginDeleteOptions) (WorkspacesDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, workspaceName, options) + if err != nil { + return WorkspacesDeletePollerResponse{}, err + } + result := WorkspacesDeletePollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("WorkspacesClient.Delete", "", resp, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return WorkspacesDeletePollerResponse{}, err + } + poller := &workspacesDeletePoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (WorkspacesDeleteResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeDelete creates a new WorkspacesDeletePoller from the specified resume token. +// token - The value must come from a previous call to WorkspacesDeletePoller.ResumeToken(). +func (client *WorkspacesClient) ResumeDelete(ctx context.Context, token string) (WorkspacesDeletePollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("WorkspacesClient.Delete", token, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return WorkspacesDeletePollerResponse{}, err + } + poller := &workspacesDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return WorkspacesDeletePollerResponse{}, err + } + result := WorkspacesDeletePollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (WorkspacesDeleteResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Delete - Deletes a workspace resource. To recover the workspace, create it again with the same name, in the same subscription, resource group and location. +// The name is kept for 14 days and cannot be used for +// another workspace. To remove the workspace completely and release the name, use the force flag. +// If the operation fails it returns the *ErrorResponse error type. +func (client *WorkspacesClient) deleteOperation(ctx context.Context, resourceGroupName string, workspaceName string, options *WorkspacesBeginDeleteOptions) (*azcore.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, workspaceName, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *WorkspacesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, options *WorkspacesBeginDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-10-01") + if options != nil && options.Force != nil { + reqQP.Set("force", strconv.FormatBool(*options.Force)) + } + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *WorkspacesClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets a workspace instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *WorkspacesClient) Get(ctx context.Context, resourceGroupName string, workspaceName string, options *WorkspacesGetOptions) (WorkspacesGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, workspaceName, options) + if err != nil { + return WorkspacesGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return WorkspacesGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return WorkspacesGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *WorkspacesClient) getCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, options *WorkspacesGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-10-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *WorkspacesClient) getHandleResponse(resp *azcore.Response) (WorkspacesGetResponse, error) { + result := WorkspacesGetResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.Workspace); err != nil { + return WorkspacesGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *WorkspacesClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// List - Gets the workspaces in a subscription. +// If the operation fails it returns the *ErrorResponse error type. +func (client *WorkspacesClient) List(ctx context.Context, options *WorkspacesListOptions) (WorkspacesListResponse, error) { + req, err := client.listCreateRequest(ctx, options) + if err != nil { + return WorkspacesListResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return WorkspacesListResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return WorkspacesListResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *WorkspacesClient) listCreateRequest(ctx context.Context, options *WorkspacesListOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.OperationalInsights/workspaces" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-10-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *WorkspacesClient) listHandleResponse(resp *azcore.Response) (WorkspacesListResponse, error) { + result := WorkspacesListResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.WorkspaceListResult); err != nil { + return WorkspacesListResponse{}, err + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *WorkspacesClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByResourceGroup - Gets workspaces in a resource group. +// If the operation fails it returns the *ErrorResponse error type. +func (client *WorkspacesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, options *WorkspacesListByResourceGroupOptions) (WorkspacesListByResourceGroupResponse, error) { + req, err := client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + if err != nil { + return WorkspacesListByResourceGroupResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return WorkspacesListByResourceGroupResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return WorkspacesListByResourceGroupResponse{}, client.listByResourceGroupHandleError(resp) + } + return client.listByResourceGroupHandleResponse(resp) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *WorkspacesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *WorkspacesListByResourceGroupOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-10-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *WorkspacesClient) listByResourceGroupHandleResponse(resp *azcore.Response) (WorkspacesListByResourceGroupResponse, error) { + result := WorkspacesListByResourceGroupResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.WorkspaceListResult); err != nil { + return WorkspacesListByResourceGroupResponse{}, err + } + return result, nil +} + +// listByResourceGroupHandleError handles the ListByResourceGroup error response. +func (client *WorkspacesClient) listByResourceGroupHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Update - Updates a workspace. +// If the operation fails it returns the *ErrorResponse error type. +func (client *WorkspacesClient) Update(ctx context.Context, resourceGroupName string, workspaceName string, parameters WorkspacePatch, options *WorkspacesUpdateOptions) (WorkspacesUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, workspaceName, parameters, options) + if err != nil { + return WorkspacesUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return WorkspacesUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return WorkspacesUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *WorkspacesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, parameters WorkspacePatch, options *WorkspacesUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if workspaceName == "" { + return nil, errors.New("parameter workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-10-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// updateHandleResponse handles the Update response. +func (client *WorkspacesClient) updateHandleResponse(resp *azcore.Response) (WorkspacesUpdateResponse, error) { + result := WorkspacesUpdateResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.Workspace); err != nil { + return WorkspacesUpdateResponse{}, err + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *WorkspacesClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +}