diff --git a/sdk/resourcemanager/elastic/armelastic/CHANGELOG.md b/sdk/resourcemanager/elastic/armelastic/CHANGELOG.md new file mode 100644 index 000000000000..8b8db847a1a2 --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/CHANGELOG.md @@ -0,0 +1,3 @@ +# Release History + +## 0.1.0 (2021-11-30) diff --git a/sdk/resourcemanager/elastic/armelastic/LICENSE.txt b/sdk/resourcemanager/elastic/armelastic/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Microsoft Corporation. All rights reserved. + +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/resourcemanager/elastic/armelastic/README.md b/sdk/resourcemanager/elastic/armelastic/README.md new file mode 100644 index 000000000000..6852ca63bc52 --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/README.md @@ -0,0 +1,75 @@ +# Azure Elastic Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic) + +The `armelastic` module provides operations for working with Azure Elastic. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/elastic/armelastic) + +# 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 Elastic module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Elastic. 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). + +## Clients + +Azure Elastic 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 credential. + +```go +client := armelastic.NewVMHostClient(, cred, nil) +``` + +You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). + +```go +options = arm.ClientOptions{ + Host: arm.AzureChina, +} +client := armelastic.NewVMHostClient(, cred, &options) +``` + +## 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 `Elastic` 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/resourcemanager/elastic/armelastic/autorest.md b/sdk/resourcemanager/elastic/armelastic/autorest.md new file mode 100644 index 000000000000..64ed69ea0481 --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/autorest.md @@ -0,0 +1,13 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- /home/vsts/work/1/s/azure-rest-api-specs/specification/elastic/resource-manager/readme.md +- /home/vsts/work/1/s/azure-rest-api-specs/specification/elastic/resource-manager/readme.go.md +license-header: MICROSOFT_MIT_NO_VERSION +module-version: 0.1.0 + +``` \ No newline at end of file diff --git a/sdk/resourcemanager/elastic/armelastic/build.go b/sdk/resourcemanager/elastic/armelastic/build.go new file mode 100644 index 000000000000..3515ee2ab628 --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/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 -cleanGenerated -format -tidy -generate resourcemanager/elastic/armelastic + +package armelastic diff --git a/sdk/resourcemanager/elastic/armelastic/ci.yml b/sdk/resourcemanager/elastic/armelastic/ci.yml new file mode 100644 index 000000000000..c216565ea60d --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/ci.yml @@ -0,0 +1,27 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. +trigger: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/elastic/armelastic/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/elastic/armelastic/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/elastic/armelastic' diff --git a/sdk/resourcemanager/elastic/armelastic/go.mod b/sdk/resourcemanager/elastic/armelastic/go.mod new file mode 100644 index 000000000000..9f54812dd24f --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/go.mod @@ -0,0 +1,8 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic + +go 1.16 + +require ( + github.com/Azure/azure-sdk-for-go v59.4.0+incompatible + github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0 +) diff --git a/sdk/resourcemanager/elastic/armelastic/go.sum b/sdk/resourcemanager/elastic/armelastic/go.sum new file mode 100644 index 000000000000..aa6cc05eede2 --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/go.sum @@ -0,0 +1,37 @@ +github.com/Azure/azure-sdk-for-go v59.4.0+incompatible h1:gDA8odnngdNd3KYHL2NoK1j9vpWBgEnFSjKKLpkC8Aw= +github.com/Azure/azure-sdk-for-go v59.4.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0 h1:KQgdWmEOmaJKxaUUZwHAYh12t+b+ZJf8q3friycK1kA= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0/go.mod h1:ZPW/Z0kLCTdDZaDbYTetxc9Cxl/2lNqxYHYNOF2bti0= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.1 h1:BUYIbDf/mMZ8945v3QkG3OuqGVyS4Iek0AOLwdRAYoc= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.1/go.mod h1:KLF4gFr6DcKFZwSuH8w8yEK6DpFl3LP5rhdvAb7Yz5I= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= +github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +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/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210610132358-84b48f89b13b h1:k+E048sYJHyVnsr1GDrRZWQ32D2C7lWs9JRc0bel53A= +golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +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/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/elastic/armelastic/go_mod_tidy_hack.go b/sdk/resourcemanager/elastic/armelastic/go_mod_tidy_hack.go new file mode 100644 index 000000000000..9a35df49212f --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/go_mod_tidy_hack.go @@ -0,0 +1,13 @@ +//go:build modhack +// +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 armelastic + +// 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/resourcemanager/elastic/armelastic/zz_generated_constants.go b/sdk/resourcemanager/elastic/armelastic/zz_generated_constants.go new file mode 100644 index 000000000000..9323de99d651 --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/zz_generated_constants.go @@ -0,0 +1,218 @@ +//go:build go1.16 +// +build go1.16 + +// 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 armelastic + +const ( + module = "armelastic" + version = "v0.1.0" +) + +// CreatedByType - The type of identity that created the resource. +type CreatedByType string + +const ( + CreatedByTypeApplication CreatedByType = "Application" + CreatedByTypeKey CreatedByType = "Key" + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + CreatedByTypeUser CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns the possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{ + CreatedByTypeApplication, + CreatedByTypeKey, + CreatedByTypeManagedIdentity, + CreatedByTypeUser, + } +} + +// ToPtr returns a *CreatedByType pointing to the current value. +func (c CreatedByType) ToPtr() *CreatedByType { + return &c +} + +// ElasticDeploymentStatus - Flag specifying if the Elastic deployment status is healthy or not. +type ElasticDeploymentStatus string + +const ( + ElasticDeploymentStatusHealthy ElasticDeploymentStatus = "Healthy" + ElasticDeploymentStatusUnhealthy ElasticDeploymentStatus = "Unhealthy" +) + +// PossibleElasticDeploymentStatusValues returns the possible values for the ElasticDeploymentStatus const type. +func PossibleElasticDeploymentStatusValues() []ElasticDeploymentStatus { + return []ElasticDeploymentStatus{ + ElasticDeploymentStatusHealthy, + ElasticDeploymentStatusUnhealthy, + } +} + +// ToPtr returns a *ElasticDeploymentStatus pointing to the current value. +func (c ElasticDeploymentStatus) ToPtr() *ElasticDeploymentStatus { + return &c +} + +type LiftrResourceCategories string + +const ( + LiftrResourceCategoriesMonitorLogs LiftrResourceCategories = "MonitorLogs" + LiftrResourceCategoriesUnknown LiftrResourceCategories = "Unknown" +) + +// PossibleLiftrResourceCategoriesValues returns the possible values for the LiftrResourceCategories const type. +func PossibleLiftrResourceCategoriesValues() []LiftrResourceCategories { + return []LiftrResourceCategories{ + LiftrResourceCategoriesMonitorLogs, + LiftrResourceCategoriesUnknown, + } +} + +// ToPtr returns a *LiftrResourceCategories pointing to the current value. +func (c LiftrResourceCategories) ToPtr() *LiftrResourceCategories { + return &c +} + +// ManagedIdentityTypes - Managed Identity types. +type ManagedIdentityTypes string + +const ( + ManagedIdentityTypesSystemAssigned ManagedIdentityTypes = "SystemAssigned" +) + +// PossibleManagedIdentityTypesValues returns the possible values for the ManagedIdentityTypes const type. +func PossibleManagedIdentityTypesValues() []ManagedIdentityTypes { + return []ManagedIdentityTypes{ + ManagedIdentityTypesSystemAssigned, + } +} + +// ToPtr returns a *ManagedIdentityTypes pointing to the current value. +func (c ManagedIdentityTypes) ToPtr() *ManagedIdentityTypes { + return &c +} + +// MonitoringStatus - Flag specifying if the resource monitoring is enabled or disabled. +type MonitoringStatus string + +const ( + MonitoringStatusDisabled MonitoringStatus = "Disabled" + MonitoringStatusEnabled MonitoringStatus = "Enabled" +) + +// PossibleMonitoringStatusValues returns the possible values for the MonitoringStatus const type. +func PossibleMonitoringStatusValues() []MonitoringStatus { + return []MonitoringStatus{ + MonitoringStatusDisabled, + MonitoringStatusEnabled, + } +} + +// ToPtr returns a *MonitoringStatus pointing to the current value. +func (c MonitoringStatus) ToPtr() *MonitoringStatus { + return &c +} + +// OperationName - Operation to be performed on the given vm resource id. +type OperationName string + +const ( + OperationNameAdd OperationName = "Add" + OperationNameDelete OperationName = "Delete" +) + +// PossibleOperationNameValues returns the possible values for the OperationName const type. +func PossibleOperationNameValues() []OperationName { + return []OperationName{ + OperationNameAdd, + OperationNameDelete, + } +} + +// ToPtr returns a *OperationName pointing to the current value. +func (c OperationName) ToPtr() *OperationName { + return &c +} + +// ProvisioningState - Provisioning state of Elastic resource. +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleted ProvisioningState = "Deleted" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateNotSpecified ProvisioningState = "NotSpecified" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateAccepted, + ProvisioningStateCanceled, + ProvisioningStateCreating, + ProvisioningStateDeleted, + ProvisioningStateDeleting, + ProvisioningStateFailed, + ProvisioningStateNotSpecified, + ProvisioningStateSucceeded, + ProvisioningStateUpdating, + } +} + +// ToPtr returns a *ProvisioningState pointing to the current value. +func (c ProvisioningState) ToPtr() *ProvisioningState { + return &c +} + +// SendingLogs - Flag indicating the status of the resource for sending logs operation to Elastic. +type SendingLogs string + +const ( + SendingLogsFalse SendingLogs = "False" + SendingLogsTrue SendingLogs = "True" +) + +// PossibleSendingLogsValues returns the possible values for the SendingLogs const type. +func PossibleSendingLogsValues() []SendingLogs { + return []SendingLogs{ + SendingLogsFalse, + SendingLogsTrue, + } +} + +// ToPtr returns a *SendingLogs pointing to the current value. +func (c SendingLogs) ToPtr() *SendingLogs { + return &c +} + +// TagAction - Valid actions for a filtering tag. Exclusion takes priority over inclusion. +type TagAction string + +const ( + TagActionExclude TagAction = "Exclude" + TagActionInclude TagAction = "Include" +) + +// PossibleTagActionValues returns the possible values for the TagAction const type. +func PossibleTagActionValues() []TagAction { + return []TagAction{ + TagActionExclude, + TagActionInclude, + } +} + +// ToPtr returns a *TagAction pointing to the current value. +func (c TagAction) ToPtr() *TagAction { + return &c +} diff --git a/sdk/resourcemanager/elastic/armelastic/zz_generated_deploymentinfo_client.go b/sdk/resourcemanager/elastic/armelastic/zz_generated_deploymentinfo_client.go new file mode 100644 index 000000000000..0744d06986a0 --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/zz_generated_deploymentinfo_client.go @@ -0,0 +1,108 @@ +//go:build go1.16 +// +build go1.16 + +// 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 armelastic + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// DeploymentInfoClient contains the methods for the DeploymentInfo group. +// Don't use this type directly, use NewDeploymentInfoClient() instead. +type DeploymentInfoClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewDeploymentInfoClient creates a new instance of DeploymentInfoClient with the specified values. +func NewDeploymentInfoClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *DeploymentInfoClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &DeploymentInfoClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// List - Fetch information regarding Elastic cloud deployment corresponding to the Elastic monitor resource. +// If the operation fails it returns the *ResourceProviderDefaultErrorResponse error type. +func (client *DeploymentInfoClient) List(ctx context.Context, resourceGroupName string, monitorName string, options *DeploymentInfoListOptions) (DeploymentInfoListResponse, error) { + req, err := client.listCreateRequest(ctx, resourceGroupName, monitorName, options) + if err != nil { + return DeploymentInfoListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return DeploymentInfoListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DeploymentInfoListResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *DeploymentInfoClient) listCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, options *DeploymentInfoListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/listDeploymentInfo" + 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 monitorName == "" { + return nil, errors.New("parameter monitorName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *DeploymentInfoClient) listHandleResponse(resp *http.Response) (DeploymentInfoListResponse, error) { + result := DeploymentInfoListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentInfoResponse); err != nil { + return DeploymentInfoListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *DeploymentInfoClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ResourceProviderDefaultErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/elastic/armelastic/zz_generated_models.go b/sdk/resourcemanager/elastic/armelastic/zz_generated_models.go new file mode 100644 index 000000000000..1cc03ce27108 --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/zz_generated_models.go @@ -0,0 +1,635 @@ +//go:build go1.16 +// +build go1.16 + +// 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 armelastic + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "time" +) + +// CompanyInfo - Company information of the user to be passed to partners. +type CompanyInfo struct { + // Business of the company + Business *string `json:"business,omitempty"` + + // Country of the company location. + Country *string `json:"country,omitempty"` + + // Domain of the company + Domain *string `json:"domain,omitempty"` + + // Number of employees in the company + EmployeesNumber *string `json:"employeesNumber,omitempty"` + + // State of the company location. + State *string `json:"state,omitempty"` +} + +// DeploymentInfoListOptions contains the optional parameters for the DeploymentInfo.List method. +type DeploymentInfoListOptions struct { + // placeholder for future optional parameters +} + +// DeploymentInfoResponse - The properties of deployment in Elastic cloud corresponding to the Elastic monitor resource. +type DeploymentInfoResponse struct { + // READ-ONLY; Disk capacity of the elasticsearch in Elastic cloud deployment. + DiskCapacity *string `json:"diskCapacity,omitempty" azure:"ro"` + + // READ-ONLY; RAM capacity of the elasticsearch in Elastic cloud deployment. + MemoryCapacity *string `json:"memoryCapacity,omitempty" azure:"ro"` + + // READ-ONLY; The Elastic deployment status. + Status *ElasticDeploymentStatus `json:"status,omitempty" azure:"ro"` + + // READ-ONLY; Version of the elasticsearch in Elastic cloud deployment. + Version *string `json:"version,omitempty" azure:"ro"` +} + +// ElasticCloudDeployment - Details of the user's elastic deployment associated with the monitor resource. +type ElasticCloudDeployment struct { + // READ-ONLY; Associated Azure subscription Id for the elastic deployment. + AzureSubscriptionID *string `json:"azureSubscriptionId,omitempty" azure:"ro"` + + // READ-ONLY; Elastic deployment Id + DeploymentID *string `json:"deploymentId,omitempty" azure:"ro"` + + // READ-ONLY; Region where Deployment at Elastic side took place. + ElasticsearchRegion *string `json:"elasticsearchRegion,omitempty" azure:"ro"` + + // READ-ONLY; Elasticsearch ingestion endpoint of the Elastic deployment. + ElasticsearchServiceURL *string `json:"elasticsearchServiceUrl,omitempty" azure:"ro"` + + // READ-ONLY; Kibana endpoint of the Elastic deployment. + KibanaServiceURL *string `json:"kibanaServiceUrl,omitempty" azure:"ro"` + + // READ-ONLY; Kibana dashboard sso URL of the Elastic deployment. + KibanaSsoURL *string `json:"kibanaSsoUrl,omitempty" azure:"ro"` + + // READ-ONLY; Elastic deployment name + Name *string `json:"name,omitempty" azure:"ro"` +} + +// ElasticCloudUser - Details of the user's elastic account. +type ElasticCloudUser struct { + // READ-ONLY; Elastic cloud default dashboard sso URL of the Elastic user account. + ElasticCloudSsoDefaultURL *string `json:"elasticCloudSsoDefaultUrl,omitempty" azure:"ro"` + + // READ-ONLY; Email of the Elastic User Account. + EmailAddress *string `json:"emailAddress,omitempty" azure:"ro"` + + // READ-ONLY; User Id of the elastic account of the User. + ID *string `json:"id,omitempty" azure:"ro"` +} + +// ElasticMonitorResource - Monitor resource. +type ElasticMonitorResource struct { + // REQUIRED; The location of the monitor resource + Location *string `json:"location,omitempty"` + + // Identity properties of the monitor resource. + Identity *IdentityProperties `json:"identity,omitempty"` + + // Properties of the monitor resource. + Properties *MonitorProperties `json:"properties,omitempty"` + + // SKU of the monitor resource. + SKU *ResourceSKU `json:"sku,omitempty"` + + // The tags of the monitor resource. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; ARM id of the monitor resource. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Name of the monitor resource. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The system metadata relating to this resource + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the monitor resource. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ElasticMonitorResource. +func (e ElasticMonitorResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", e.ID) + populate(objectMap, "identity", e.Identity) + populate(objectMap, "location", e.Location) + populate(objectMap, "name", e.Name) + populate(objectMap, "properties", e.Properties) + populate(objectMap, "sku", e.SKU) + populate(objectMap, "systemData", e.SystemData) + populate(objectMap, "tags", e.Tags) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// ElasticMonitorResourceListResponse - Response of a list operation. +type ElasticMonitorResourceListResponse struct { + // Link to the next set of results, if any. + NextLink *string `json:"nextLink,omitempty"` + + // Results of a list operation. + Value []*ElasticMonitorResource `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ElasticMonitorResourceListResponse. +func (e ElasticMonitorResourceListResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", e.NextLink) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// ElasticMonitorResourceUpdateParameters - Monitor resource update parameters. +type ElasticMonitorResourceUpdateParameters struct { + // elastic monitor resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ElasticMonitorResourceUpdateParameters. +func (e ElasticMonitorResourceUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "tags", e.Tags) + return json.Marshal(objectMap) +} + +// ElasticProperties - Elastic Resource Properties. +type ElasticProperties struct { + // Details of the elastic cloud deployment. + ElasticCloudDeployment *ElasticCloudDeployment `json:"elasticCloudDeployment,omitempty"` + + // Details of the user's elastic account. + ElasticCloudUser *ElasticCloudUser `json:"elasticCloudUser,omitempty"` +} + +// ErrorResponseBody - Error response body. +type ErrorResponseBody struct { + // Error code. + Code *string `json:"code,omitempty"` + + // Error details. + Details []*ErrorResponseBody `json:"details,omitempty"` + + // Error message. + Message *string `json:"message,omitempty"` + + // Error target. + Target *string `json:"target,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorResponseBody. +func (e ErrorResponseBody) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + populate(objectMap, "target", e.Target) + return json.Marshal(objectMap) +} + +// FilteringTag - The definition of a filtering tag. Filtering tags are used for capturing resources and include/exclude them from being monitored. +type FilteringTag struct { + // Valid actions for a filtering tag. + Action *TagAction `json:"action,omitempty"` + + // The name (also known as the key) of the tag. + Name *string `json:"name,omitempty"` + + // The value of the tag. + Value *string `json:"value,omitempty"` +} + +// IdentityProperties - Identity properties. +type IdentityProperties struct { + // Managed identity type. + Type *ManagedIdentityTypes `json:"type,omitempty"` + + // READ-ONLY; The identity ID. + PrincipalID *string `json:"principalId,omitempty" azure:"ro"` + + // READ-ONLY; The tenant ID of resource. + TenantID *string `json:"tenantId,omitempty" azure:"ro"` +} + +// LogRules - Set of rules for sending logs for the Monitor resource. +type LogRules struct { + // List of filtering tags to be used for capturing logs. This only takes effect if SendActivityLogs flag is enabled. If empty, all resources will be captured. + // If only Exclude action is specified, the + // rules will apply to the list of all available resources. If Include actions are specified, the rules will only include resources with the associated + // tags. + FilteringTags []*FilteringTag `json:"filteringTags,omitempty"` + + // Flag specifying if AAD logs should be sent for the Monitor resource. + SendAADLogs *bool `json:"sendAadLogs,omitempty"` + + // Flag specifying if activity logs from Azure resources should be sent for the Monitor resource. + SendActivityLogs *bool `json:"sendActivityLogs,omitempty"` + + // Flag specifying if subscription logs should be sent for the Monitor resource. + SendSubscriptionLogs *bool `json:"sendSubscriptionLogs,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type LogRules. +func (l LogRules) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "filteringTags", l.FilteringTags) + populate(objectMap, "sendAadLogs", l.SendAADLogs) + populate(objectMap, "sendActivityLogs", l.SendActivityLogs) + populate(objectMap, "sendSubscriptionLogs", l.SendSubscriptionLogs) + return json.Marshal(objectMap) +} + +// MonitorProperties - Properties specific to the monitor resource. +type MonitorProperties struct { + // Elastic cloud properties. + ElasticProperties *ElasticProperties `json:"elasticProperties,omitempty"` + + // Flag specifying if the resource monitoring is enabled or disabled. + MonitoringStatus *MonitoringStatus `json:"monitoringStatus,omitempty"` + + // Provisioning state of the monitor resource. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + + // User information. + UserInfo *UserInfo `json:"userInfo,omitempty"` + + // READ-ONLY + LiftrResourceCategory *LiftrResourceCategories `json:"liftrResourceCategory,omitempty" azure:"ro"` + + // READ-ONLY; The priority of the resource. + LiftrResourcePreference *int32 `json:"liftrResourcePreference,omitempty" azure:"ro"` +} + +// MonitoredResource - The properties of a resource currently being monitored by the Elastic monitor resource. +type MonitoredResource struct { + // The ARM id of the resource. + ID *string `json:"id,omitempty"` + + // Reason for why the resource is sending logs (or why it is not sending). + ReasonForLogsStatus *string `json:"reasonForLogsStatus,omitempty"` + + // Flag indicating the status of the resource for sending logs operation to Elastic. + SendingLogs *SendingLogs `json:"sendingLogs,omitempty"` +} + +// MonitoredResourceListResponse - Response of a list operation. +type MonitoredResourceListResponse struct { + // Link to the next set of results, if any. + NextLink *string `json:"nextLink,omitempty"` + + // Results of a list operation. + Value []*MonitoredResource `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type MonitoredResourceListResponse. +func (m MonitoredResourceListResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", m.NextLink) + populate(objectMap, "value", m.Value) + return json.Marshal(objectMap) +} + +// MonitoredResourcesListOptions contains the optional parameters for the MonitoredResources.List method. +type MonitoredResourcesListOptions struct { + // placeholder for future optional parameters +} + +// MonitoringTagRules - Capture logs and metrics of Azure resources based on ARM tags. +type MonitoringTagRules struct { + // Properties of the monitoring tag rules. + Properties *MonitoringTagRulesProperties `json:"properties,omitempty"` + + // READ-ONLY; The id of the rule set. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Name of the rule set. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The system metadata relating to this resource + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the rule set. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// MonitoringTagRulesListResponse - Response of a list operation. +type MonitoringTagRulesListResponse struct { + // Link to the next set of results, if any. + NextLink *string `json:"nextLink,omitempty"` + + // Results of a list operation. + Value []*MonitoringTagRules `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type MonitoringTagRulesListResponse. +func (m MonitoringTagRulesListResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", m.NextLink) + populate(objectMap, "value", m.Value) + return json.Marshal(objectMap) +} + +// MonitoringTagRulesProperties - Definition of the properties for a TagRules resource. +type MonitoringTagRulesProperties struct { + // Rules for sending logs. + LogRules *LogRules `json:"logRules,omitempty"` + + // Provisioning state of the monitoring tag rules. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} + +// MonitorsBeginCreateOptions contains the optional parameters for the Monitors.BeginCreate method. +type MonitorsBeginCreateOptions struct { + // Elastic monitor resource model + Body *ElasticMonitorResource +} + +// MonitorsBeginDeleteOptions contains the optional parameters for the Monitors.BeginDelete method. +type MonitorsBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// MonitorsGetOptions contains the optional parameters for the Monitors.Get method. +type MonitorsGetOptions struct { + // placeholder for future optional parameters +} + +// MonitorsListByResourceGroupOptions contains the optional parameters for the Monitors.ListByResourceGroup method. +type MonitorsListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// MonitorsListOptions contains the optional parameters for the Monitors.List method. +type MonitorsListOptions struct { + // placeholder for future optional parameters +} + +// MonitorsUpdateOptions contains the optional parameters for the Monitors.Update method. +type MonitorsUpdateOptions struct { + // Elastic resource model update parameters. + Body *ElasticMonitorResourceUpdateParameters +} + +// OperationDisplay - The object that represents the operation. +type OperationDisplay struct { + // Description of the operation, e.g., 'Write monitors'. + Description *string `json:"description,omitempty"` + + // Operation type, e.g., read, write, delete, etc. + Operation *string `json:"operation,omitempty"` + + // Service provider, i.e., Microsoft.Elastic. + Provider *string `json:"provider,omitempty"` + + // Type on which the operation is performed, e.g., 'monitors'. + Resource *string `json:"resource,omitempty"` +} + +// OperationListResult - Result of GET request to list the Microsoft.Elastic operations. +type OperationListResult struct { + // URL to get the next set of operation list results if there are any. + NextLink *string `json:"nextLink,omitempty"` + + // List of operations supported by the Microsoft.Elastic provider. + Value []*OperationResult `json:"value,omitempty"` +} + +// 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) +} + +// OperationResult - A Microsoft.Elastic REST API operation. +type OperationResult struct { + // The object that represents the operation. + Display *OperationDisplay `json:"display,omitempty"` + + // Indicates whether the operation is a data action + IsDataAction *bool `json:"isDataAction,omitempty"` + + // Operation name, i.e., {provider}/{resource}/{operation}. + Name *string `json:"name,omitempty"` + + // Origin of the operation + Origin *string `json:"origin,omitempty"` +} + +// OperationsListOptions contains the optional parameters for the Operations.List method. +type OperationsListOptions struct { + // placeholder for future optional parameters +} + +// ResourceProviderDefaultErrorResponse - RP default error response. +// Implements the error and azcore.HTTPResponse interfaces. +type ResourceProviderDefaultErrorResponse struct { + raw string + // READ-ONLY; Response body of Error + InnerError *ErrorResponseBody `json:"error,omitempty" azure:"ro"` +} + +// Error implements the error interface for type ResourceProviderDefaultErrorResponse. +// The contents of the error text are not contractual and subject to change. +func (e ResourceProviderDefaultErrorResponse) Error() string { + return e.raw +} + +// ResourceSKU - Microsoft.Elastic SKU. +type ResourceSKU struct { + // REQUIRED; Name of the SKU. + Name *string `json:"name,omitempty"` +} + +// SystemData - Metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // The timestamp of resource creation (UTC). + CreatedAt *time.Time `json:"createdAt,omitempty"` + + // The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + + // The type of identity that created the resource. + CreatedByType *CreatedByType `json:"createdByType,omitempty"` + + // The timestamp of resource last modification (UTC) + LastModifiedAt *time.Time `json:"lastModifiedAt,omitempty"` + + // The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + + // The type of identity that last modified the resource. + LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) 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 "createdAt": + err = unpopulateTimeRFC3339(val, &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// TagRulesBeginDeleteOptions contains the optional parameters for the TagRules.BeginDelete method. +type TagRulesBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// TagRulesCreateOrUpdateOptions contains the optional parameters for the TagRules.CreateOrUpdate method. +type TagRulesCreateOrUpdateOptions struct { + // request body of MonitoringTagRules + Body *MonitoringTagRules +} + +// TagRulesGetOptions contains the optional parameters for the TagRules.Get method. +type TagRulesGetOptions struct { + // placeholder for future optional parameters +} + +// TagRulesListOptions contains the optional parameters for the TagRules.List method. +type TagRulesListOptions struct { + // placeholder for future optional parameters +} + +// UserInfo - User Information to be passed to partners. +type UserInfo struct { + // Company information of the user to be passed to partners. + CompanyInfo *CompanyInfo `json:"companyInfo,omitempty"` + + // Company name of the user + CompanyName *string `json:"companyName,omitempty"` + + // Email of the user used by Elastic for contacting them if needed + EmailAddress *string `json:"emailAddress,omitempty"` + + // First name of the user + FirstName *string `json:"firstName,omitempty"` + + // Last name of the user + LastName *string `json:"lastName,omitempty"` +} + +// VMCollectionUpdate - Update VM resource collection. +type VMCollectionUpdate struct { + // Operation to be performed for given VM. + OperationName *OperationName `json:"operationName,omitempty"` + + // ARM id of the VM resource. + VMResourceID *string `json:"vmResourceId,omitempty"` +} + +// VMCollectionUpdateOptions contains the optional parameters for the VMCollection.Update method. +type VMCollectionUpdateOptions struct { + // VM resource Id + Body *VMCollectionUpdate +} + +// VMHostListOptions contains the optional parameters for the VMHost.List method. +type VMHostListOptions struct { + // placeholder for future optional parameters +} + +// VMHostListResponse - Response of a list operation. +type VMHostListResponse struct { + // Link to the next Vm resource Id, if any. + NextLink *string `json:"nextLink,omitempty"` + + // Results of a list operation. + Value []*VMResources `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type VMHostListResponse. +func (v VMHostListResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", v.NextLink) + populate(objectMap, "value", v.Value) + return json.Marshal(objectMap) +} + +// VMIngestionDetailsOptions contains the optional parameters for the VMIngestion.Details method. +type VMIngestionDetailsOptions struct { + // placeholder for future optional parameters +} + +// VMIngestionDetailsResponse - The vm ingestion details to install an agent. +type VMIngestionDetailsResponse struct { + // The cloudId of given Elastic monitor resource. + CloudID *string `json:"cloudId,omitempty"` + + // Ingestion details to install agent on given VM. + IngestionKey *string `json:"ingestionKey,omitempty"` +} + +// VMResources - The vm resource properties that is currently being monitored by the Elastic monitor resource. +type VMResources struct { + // The ARM id of the VM resource. + VMResourceID *string `json:"vmResourceId,omitempty"` +} + +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/resourcemanager/elastic/armelastic/zz_generated_monitoredresources_client.go b/sdk/resourcemanager/elastic/armelastic/zz_generated_monitoredresources_client.go new file mode 100644 index 000000000000..3f3f4ab57340 --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/zz_generated_monitoredresources_client.go @@ -0,0 +1,105 @@ +//go:build go1.16 +// +build go1.16 + +// 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 armelastic + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// MonitoredResourcesClient contains the methods for the MonitoredResources group. +// Don't use this type directly, use NewMonitoredResourcesClient() instead. +type MonitoredResourcesClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewMonitoredResourcesClient creates a new instance of MonitoredResourcesClient with the specified values. +func NewMonitoredResourcesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *MonitoredResourcesClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &MonitoredResourcesClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// List - List the resources currently being monitored by the Elastic monitor resource. +// If the operation fails it returns the *ResourceProviderDefaultErrorResponse error type. +func (client *MonitoredResourcesClient) List(resourceGroupName string, monitorName string, options *MonitoredResourcesListOptions) *MonitoredResourcesListPager { + return &MonitoredResourcesListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, monitorName, options) + }, + advancer: func(ctx context.Context, resp MonitoredResourcesListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.MonitoredResourceListResponse.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *MonitoredResourcesClient) listCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, options *MonitoredResourcesListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/listMonitoredResources" + 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 monitorName == "" { + return nil, errors.New("parameter monitorName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *MonitoredResourcesClient) listHandleResponse(resp *http.Response) (MonitoredResourcesListResponse, error) { + result := MonitoredResourcesListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.MonitoredResourceListResponse); err != nil { + return MonitoredResourcesListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *MonitoredResourcesClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ResourceProviderDefaultErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/elastic/armelastic/zz_generated_monitors_client.go b/sdk/resourcemanager/elastic/armelastic/zz_generated_monitors_client.go new file mode 100644 index 000000000000..eb5367e7b3dd --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/zz_generated_monitors_client.go @@ -0,0 +1,443 @@ +//go:build go1.16 +// +build go1.16 + +// 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 armelastic + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// MonitorsClient contains the methods for the Monitors group. +// Don't use this type directly, use NewMonitorsClient() instead. +type MonitorsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewMonitorsClient creates a new instance of MonitorsClient with the specified values. +func NewMonitorsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *MonitorsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &MonitorsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// BeginCreate - Create a monitor resource. +// If the operation fails it returns the *ResourceProviderDefaultErrorResponse error type. +func (client *MonitorsClient) BeginCreate(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsBeginCreateOptions) (MonitorsCreatePollerResponse, error) { + resp, err := client.create(ctx, resourceGroupName, monitorName, options) + if err != nil { + return MonitorsCreatePollerResponse{}, err + } + result := MonitorsCreatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("MonitorsClient.Create", "azure-async-operation", resp, client.pl, client.createHandleError) + if err != nil { + return MonitorsCreatePollerResponse{}, err + } + result.Poller = &MonitorsCreatePoller{ + pt: pt, + } + return result, nil +} + +// Create - Create a monitor resource. +// If the operation fails it returns the *ResourceProviderDefaultErrorResponse error type. +func (client *MonitorsClient) create(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsBeginCreateOptions) (*http.Response, error) { + req, err := client.createCreateRequest(ctx, resourceGroupName, monitorName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return nil, client.createHandleError(resp) + } + return resp, nil +} + +// createCreateRequest creates the Create request. +func (client *MonitorsClient) createCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsBeginCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}" + 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 monitorName == "" { + return nil, errors.New("parameter monitorName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + if options != nil && options.Body != nil { + return req, runtime.MarshalAsJSON(req, *options.Body) + } + return req, nil +} + +// createHandleError handles the Create error response. +func (client *MonitorsClient) createHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ResourceProviderDefaultErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BeginDelete - Delete a monitor resource. +// If the operation fails it returns the *ResourceProviderDefaultErrorResponse error type. +func (client *MonitorsClient) BeginDelete(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsBeginDeleteOptions) (MonitorsDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, monitorName, options) + if err != nil { + return MonitorsDeletePollerResponse{}, err + } + result := MonitorsDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("MonitorsClient.Delete", "", resp, client.pl, client.deleteHandleError) + if err != nil { + return MonitorsDeletePollerResponse{}, err + } + result.Poller = &MonitorsDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Delete a monitor resource. +// If the operation fails it returns the *ResourceProviderDefaultErrorResponse error type. +func (client *MonitorsClient) deleteOperation(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, monitorName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *MonitorsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}" + 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 monitorName == "" { + return nil, errors.New("parameter monitorName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *MonitorsClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ResourceProviderDefaultErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Get the properties of a specific monitor resource. +// If the operation fails it returns the *ResourceProviderDefaultErrorResponse error type. +func (client *MonitorsClient) Get(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsGetOptions) (MonitorsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, monitorName, options) + if err != nil { + return MonitorsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return MonitorsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return MonitorsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *MonitorsClient) getCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}" + 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 monitorName == "" { + return nil, errors.New("parameter monitorName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *MonitorsClient) getHandleResponse(resp *http.Response) (MonitorsGetResponse, error) { + result := MonitorsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ElasticMonitorResource); err != nil { + return MonitorsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *MonitorsClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ResourceProviderDefaultErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// List - List all monitors under the specified subscription. +// If the operation fails it returns the *ResourceProviderDefaultErrorResponse error type. +func (client *MonitorsClient) List(options *MonitorsListOptions) *MonitorsListPager { + return &MonitorsListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp MonitorsListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.ElasticMonitorResourceListResponse.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *MonitorsClient) listCreateRequest(ctx context.Context, options *MonitorsListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Elastic/monitors" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *MonitorsClient) listHandleResponse(resp *http.Response) (MonitorsListResponse, error) { + result := MonitorsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ElasticMonitorResourceListResponse); err != nil { + return MonitorsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *MonitorsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ResourceProviderDefaultErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListByResourceGroup - List all monitors under the specified resource group. +// If the operation fails it returns the *ResourceProviderDefaultErrorResponse error type. +func (client *MonitorsClient) ListByResourceGroup(resourceGroupName string, options *MonitorsListByResourceGroupOptions) *MonitorsListByResourceGroupPager { + return &MonitorsListByResourceGroupPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, + advancer: func(ctx context.Context, resp MonitorsListByResourceGroupResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.ElasticMonitorResourceListResponse.NextLink) + }, + } +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *MonitorsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *MonitorsListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors" + 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)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *MonitorsClient) listByResourceGroupHandleResponse(resp *http.Response) (MonitorsListByResourceGroupResponse, error) { + result := MonitorsListByResourceGroupResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ElasticMonitorResourceListResponse); err != nil { + return MonitorsListByResourceGroupResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listByResourceGroupHandleError handles the ListByResourceGroup error response. +func (client *MonitorsClient) listByResourceGroupHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ResourceProviderDefaultErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Update - Update a monitor resource. +// If the operation fails it returns the *ResourceProviderDefaultErrorResponse error type. +func (client *MonitorsClient) Update(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsUpdateOptions) (MonitorsUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, monitorName, options) + if err != nil { + return MonitorsUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return MonitorsUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return MonitorsUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *MonitorsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}" + 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 monitorName == "" { + return nil, errors.New("parameter monitorName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + if options != nil && options.Body != nil { + return req, runtime.MarshalAsJSON(req, *options.Body) + } + return req, nil +} + +// updateHandleResponse handles the Update response. +func (client *MonitorsClient) updateHandleResponse(resp *http.Response) (MonitorsUpdateResponse, error) { + result := MonitorsUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ElasticMonitorResource); err != nil { + return MonitorsUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *MonitorsClient) updateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ResourceProviderDefaultErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/elastic/armelastic/zz_generated_operations_client.go b/sdk/resourcemanager/elastic/armelastic/zz_generated_operations_client.go new file mode 100644 index 000000000000..9972f0da243c --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/zz_generated_operations_client.go @@ -0,0 +1,89 @@ +//go:build go1.16 +// +build go1.16 + +// 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 armelastic + +import ( + "context" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" +) + +// OperationsClient contains the methods for the Operations group. +// Don't use this type directly, use NewOperationsClient() instead. +type OperationsClient struct { + ep string + pl runtime.Pipeline +} + +// NewOperationsClient creates a new instance of OperationsClient with the specified values. +func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) *OperationsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &OperationsClient{ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// List - List all operations provided by Microsoft.Elastic. +// If the operation fails it returns the *ResourceProviderDefaultErrorResponse error type. +func (client *OperationsClient) List(options *OperationsListOptions) *OperationsListPager { + return &OperationsListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp OperationsListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.OperationListResult.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Elastic/operations" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsListResponse, error) { + result := OperationsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationListResult); err != nil { + return OperationsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *OperationsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ResourceProviderDefaultErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/elastic/armelastic/zz_generated_pagers.go b/sdk/resourcemanager/elastic/armelastic/zz_generated_pagers.go new file mode 100644 index 000000000000..8e0dc560f854 --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/zz_generated_pagers.go @@ -0,0 +1,341 @@ +//go:build go1.16 +// +build go1.16 + +// 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 armelastic + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "reflect" +) + +// MonitoredResourcesListPager provides operations for iterating over paged responses. +type MonitoredResourcesListPager struct { + client *MonitoredResourcesClient + current MonitoredResourcesListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, MonitoredResourcesListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *MonitoredResourcesListPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *MonitoredResourcesListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.MonitoredResourceListResponse.NextLink == nil || len(*p.current.MonitoredResourceListResponse.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.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, 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 +} + +// PageResponse returns the current MonitoredResourcesListResponse page. +func (p *MonitoredResourcesListPager) PageResponse() MonitoredResourcesListResponse { + return p.current +} + +// MonitorsListByResourceGroupPager provides operations for iterating over paged responses. +type MonitorsListByResourceGroupPager struct { + client *MonitorsClient + current MonitorsListByResourceGroupResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, MonitorsListByResourceGroupResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *MonitorsListByResourceGroupPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *MonitorsListByResourceGroupPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ElasticMonitorResourceListResponse.NextLink == nil || len(*p.current.ElasticMonitorResourceListResponse.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.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, 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 +} + +// PageResponse returns the current MonitorsListByResourceGroupResponse page. +func (p *MonitorsListByResourceGroupPager) PageResponse() MonitorsListByResourceGroupResponse { + return p.current +} + +// MonitorsListPager provides operations for iterating over paged responses. +type MonitorsListPager struct { + client *MonitorsClient + current MonitorsListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, MonitorsListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *MonitorsListPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *MonitorsListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ElasticMonitorResourceListResponse.NextLink == nil || len(*p.current.ElasticMonitorResourceListResponse.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.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, 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 +} + +// PageResponse returns the current MonitorsListResponse page. +func (p *MonitorsListPager) PageResponse() MonitorsListResponse { + return p.current +} + +// OperationsListPager provides operations for iterating over paged responses. +type OperationsListPager struct { + client *OperationsClient + current OperationsListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, OperationsListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *OperationsListPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *OperationsListPager) NextPage(ctx context.Context) bool { + var req *policy.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.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, 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 +} + +// PageResponse returns the current OperationsListResponse page. +func (p *OperationsListPager) PageResponse() OperationsListResponse { + return p.current +} + +// TagRulesListPager provides operations for iterating over paged responses. +type TagRulesListPager struct { + client *TagRulesClient + current TagRulesListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, TagRulesListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *TagRulesListPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *TagRulesListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.MonitoringTagRulesListResponse.NextLink == nil || len(*p.current.MonitoringTagRulesListResponse.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.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, 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 +} + +// PageResponse returns the current TagRulesListResponse page. +func (p *TagRulesListPager) PageResponse() TagRulesListResponse { + return p.current +} + +// VMHostListPager provides operations for iterating over paged responses. +type VMHostListPager struct { + client *VMHostClient + current VMHostListResponseEnvelope + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, VMHostListResponseEnvelope) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *VMHostListPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *VMHostListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.VMHostListResponse.NextLink == nil || len(*p.current.VMHostListResponse.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.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, 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 +} + +// PageResponse returns the current VMHostListResponseEnvelope page. +func (p *VMHostListPager) PageResponse() VMHostListResponseEnvelope { + return p.current +} diff --git a/sdk/resourcemanager/elastic/armelastic/zz_generated_pollers.go b/sdk/resourcemanager/elastic/armelastic/zz_generated_pollers.go new file mode 100644 index 000000000000..f99145582474 --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/zz_generated_pollers.go @@ -0,0 +1,144 @@ +//go:build go1.16 +// +build go1.16 + +// 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 armelastic + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" +) + +// MonitorsCreatePoller provides polling facilities until the operation reaches a terminal state. +type MonitorsCreatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *MonitorsCreatePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *MonitorsCreatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// 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 MonitorsCreateResponse will be returned. +func (p *MonitorsCreatePoller) FinalResponse(ctx context.Context) (MonitorsCreateResponse, error) { + respType := MonitorsCreateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.ElasticMonitorResource) + if err != nil { + return MonitorsCreateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *MonitorsCreatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// MonitorsDeletePoller provides polling facilities until the operation reaches a terminal state. +type MonitorsDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *MonitorsDeletePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *MonitorsDeletePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// 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 MonitorsDeleteResponse will be returned. +func (p *MonitorsDeletePoller) FinalResponse(ctx context.Context) (MonitorsDeleteResponse, error) { + respType := MonitorsDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return MonitorsDeleteResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *MonitorsDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// TagRulesDeletePoller provides polling facilities until the operation reaches a terminal state. +type TagRulesDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *TagRulesDeletePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *TagRulesDeletePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// 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 TagRulesDeleteResponse will be returned. +func (p *TagRulesDeletePoller) FinalResponse(ctx context.Context) (TagRulesDeleteResponse, error) { + respType := TagRulesDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return TagRulesDeleteResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *TagRulesDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} diff --git a/sdk/resourcemanager/elastic/armelastic/zz_generated_response_types.go b/sdk/resourcemanager/elastic/armelastic/zz_generated_response_types.go new file mode 100644 index 000000000000..8a224008fb75 --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/zz_generated_response_types.go @@ -0,0 +1,310 @@ +//go:build go1.16 +// +build go1.16 + +// 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 armelastic + +import ( + "context" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "net/http" + "time" +) + +// DeploymentInfoListResponse contains the response from method DeploymentInfo.List. +type DeploymentInfoListResponse struct { + DeploymentInfoListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DeploymentInfoListResult contains the result from method DeploymentInfo.List. +type DeploymentInfoListResult struct { + DeploymentInfoResponse +} + +// MonitoredResourcesListResponse contains the response from method MonitoredResources.List. +type MonitoredResourcesListResponse struct { + MonitoredResourcesListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// MonitoredResourcesListResult contains the result from method MonitoredResources.List. +type MonitoredResourcesListResult struct { + MonitoredResourceListResponse +} + +// MonitorsCreatePollerResponse contains the response from method Monitors.Create. +type MonitorsCreatePollerResponse struct { + // Poller contains an initialized poller. + Poller *MonitorsCreatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l MonitorsCreatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (MonitorsCreateResponse, error) { + respType := MonitorsCreateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.ElasticMonitorResource) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a MonitorsCreatePollerResponse from the provided client and resume token. +func (l *MonitorsCreatePollerResponse) Resume(ctx context.Context, client *MonitorsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("MonitorsClient.Create", token, client.pl, client.createHandleError) + if err != nil { + return err + } + poller := &MonitorsCreatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// MonitorsCreateResponse contains the response from method Monitors.Create. +type MonitorsCreateResponse struct { + MonitorsCreateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// MonitorsCreateResult contains the result from method Monitors.Create. +type MonitorsCreateResult struct { + ElasticMonitorResource +} + +// MonitorsDeletePollerResponse contains the response from method Monitors.Delete. +type MonitorsDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *MonitorsDeletePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l MonitorsDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (MonitorsDeleteResponse, error) { + respType := MonitorsDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a MonitorsDeletePollerResponse from the provided client and resume token. +func (l *MonitorsDeletePollerResponse) Resume(ctx context.Context, client *MonitorsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("MonitorsClient.Delete", token, client.pl, client.deleteHandleError) + if err != nil { + return err + } + poller := &MonitorsDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// MonitorsDeleteResponse contains the response from method Monitors.Delete. +type MonitorsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// MonitorsGetResponse contains the response from method Monitors.Get. +type MonitorsGetResponse struct { + MonitorsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// MonitorsGetResult contains the result from method Monitors.Get. +type MonitorsGetResult struct { + ElasticMonitorResource +} + +// MonitorsListByResourceGroupResponse contains the response from method Monitors.ListByResourceGroup. +type MonitorsListByResourceGroupResponse struct { + MonitorsListByResourceGroupResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// MonitorsListByResourceGroupResult contains the result from method Monitors.ListByResourceGroup. +type MonitorsListByResourceGroupResult struct { + ElasticMonitorResourceListResponse +} + +// MonitorsListResponse contains the response from method Monitors.List. +type MonitorsListResponse struct { + MonitorsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// MonitorsListResult contains the result from method Monitors.List. +type MonitorsListResult struct { + ElasticMonitorResourceListResponse +} + +// MonitorsUpdateResponse contains the response from method Monitors.Update. +type MonitorsUpdateResponse struct { + MonitorsUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// MonitorsUpdateResult contains the result from method Monitors.Update. +type MonitorsUpdateResult struct { + ElasticMonitorResource +} + +// 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 +} + +// TagRulesCreateOrUpdateResponse contains the response from method TagRules.CreateOrUpdate. +type TagRulesCreateOrUpdateResponse struct { + TagRulesCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TagRulesCreateOrUpdateResult contains the result from method TagRules.CreateOrUpdate. +type TagRulesCreateOrUpdateResult struct { + MonitoringTagRules +} + +// TagRulesDeletePollerResponse contains the response from method TagRules.Delete. +type TagRulesDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *TagRulesDeletePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l TagRulesDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (TagRulesDeleteResponse, error) { + respType := TagRulesDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a TagRulesDeletePollerResponse from the provided client and resume token. +func (l *TagRulesDeletePollerResponse) Resume(ctx context.Context, client *TagRulesClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("TagRulesClient.Delete", token, client.pl, client.deleteHandleError) + if err != nil { + return err + } + poller := &TagRulesDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// TagRulesDeleteResponse contains the response from method TagRules.Delete. +type TagRulesDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TagRulesGetResponse contains the response from method TagRules.Get. +type TagRulesGetResponse struct { + TagRulesGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TagRulesGetResult contains the result from method TagRules.Get. +type TagRulesGetResult struct { + MonitoringTagRules +} + +// TagRulesListResponse contains the response from method TagRules.List. +type TagRulesListResponse struct { + TagRulesListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TagRulesListResult contains the result from method TagRules.List. +type TagRulesListResult struct { + MonitoringTagRulesListResponse +} + +// VMCollectionUpdateResponse contains the response from method VMCollection.Update. +type VMCollectionUpdateResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// VMHostListResponseEnvelope contains the response from method VMHost.List. +type VMHostListResponseEnvelope struct { + VMHostListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// VMHostListResult contains the result from method VMHost.List. +type VMHostListResult struct { + VMHostListResponse +} + +// VMIngestionDetailsResponseEnvelope contains the response from method VMIngestion.Details. +type VMIngestionDetailsResponseEnvelope struct { + VMIngestionDetailsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// VMIngestionDetailsResult contains the result from method VMIngestion.Details. +type VMIngestionDetailsResult struct { + VMIngestionDetailsResponse +} diff --git a/sdk/resourcemanager/elastic/armelastic/zz_generated_tagrules_client.go b/sdk/resourcemanager/elastic/armelastic/zz_generated_tagrules_client.go new file mode 100644 index 000000000000..0e5e976906ed --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/zz_generated_tagrules_client.go @@ -0,0 +1,326 @@ +//go:build go1.16 +// +build go1.16 + +// 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 armelastic + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// TagRulesClient contains the methods for the TagRules group. +// Don't use this type directly, use NewTagRulesClient() instead. +type TagRulesClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewTagRulesClient creates a new instance of TagRulesClient with the specified values. +func NewTagRulesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *TagRulesClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &TagRulesClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// CreateOrUpdate - Create or update a tag rule set for a given monitor resource. +// If the operation fails it returns the *ResourceProviderDefaultErrorResponse error type. +func (client *TagRulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, options *TagRulesCreateOrUpdateOptions) (TagRulesCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, monitorName, ruleSetName, options) + if err != nil { + return TagRulesCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return TagRulesCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return TagRulesCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *TagRulesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, options *TagRulesCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/tagRules/{ruleSetName}" + 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 monitorName == "" { + return nil, errors.New("parameter monitorName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) + if ruleSetName == "" { + return nil, errors.New("parameter ruleSetName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{ruleSetName}", url.PathEscape(ruleSetName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + if options != nil && options.Body != nil { + return req, runtime.MarshalAsJSON(req, *options.Body) + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *TagRulesClient) createOrUpdateHandleResponse(resp *http.Response) (TagRulesCreateOrUpdateResponse, error) { + result := TagRulesCreateOrUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.MonitoringTagRules); err != nil { + return TagRulesCreateOrUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *TagRulesClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ResourceProviderDefaultErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BeginDelete - Delete a tag rule set for a given monitor resource. +// If the operation fails it returns the *ResourceProviderDefaultErrorResponse error type. +func (client *TagRulesClient) BeginDelete(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, options *TagRulesBeginDeleteOptions) (TagRulesDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, monitorName, ruleSetName, options) + if err != nil { + return TagRulesDeletePollerResponse{}, err + } + result := TagRulesDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("TagRulesClient.Delete", "", resp, client.pl, client.deleteHandleError) + if err != nil { + return TagRulesDeletePollerResponse{}, err + } + result.Poller = &TagRulesDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Delete a tag rule set for a given monitor resource. +// If the operation fails it returns the *ResourceProviderDefaultErrorResponse error type. +func (client *TagRulesClient) deleteOperation(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, options *TagRulesBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, monitorName, ruleSetName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *TagRulesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, options *TagRulesBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/tagRules/{ruleSetName}" + 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 monitorName == "" { + return nil, errors.New("parameter monitorName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) + if ruleSetName == "" { + return nil, errors.New("parameter ruleSetName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{ruleSetName}", url.PathEscape(ruleSetName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *TagRulesClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ResourceProviderDefaultErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Get a tag rule set for a given monitor resource. +// If the operation fails it returns the *ResourceProviderDefaultErrorResponse error type. +func (client *TagRulesClient) Get(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, options *TagRulesGetOptions) (TagRulesGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, monitorName, ruleSetName, options) + if err != nil { + return TagRulesGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return TagRulesGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return TagRulesGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *TagRulesClient) getCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, options *TagRulesGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/tagRules/{ruleSetName}" + 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 monitorName == "" { + return nil, errors.New("parameter monitorName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) + if ruleSetName == "" { + return nil, errors.New("parameter ruleSetName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{ruleSetName}", url.PathEscape(ruleSetName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *TagRulesClient) getHandleResponse(resp *http.Response) (TagRulesGetResponse, error) { + result := TagRulesGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.MonitoringTagRules); err != nil { + return TagRulesGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *TagRulesClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ResourceProviderDefaultErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// List - List the tag rules for a given monitor resource. +// If the operation fails it returns the *ResourceProviderDefaultErrorResponse error type. +func (client *TagRulesClient) List(resourceGroupName string, monitorName string, options *TagRulesListOptions) *TagRulesListPager { + return &TagRulesListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, monitorName, options) + }, + advancer: func(ctx context.Context, resp TagRulesListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.MonitoringTagRulesListResponse.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *TagRulesClient) listCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, options *TagRulesListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/tagRules" + 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 monitorName == "" { + return nil, errors.New("parameter monitorName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *TagRulesClient) listHandleResponse(resp *http.Response) (TagRulesListResponse, error) { + result := TagRulesListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.MonitoringTagRulesListResponse); err != nil { + return TagRulesListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *TagRulesClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ResourceProviderDefaultErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/elastic/armelastic/zz_generated_time_rfc3339.go b/sdk/resourcemanager/elastic/armelastic/zz_generated_time_rfc3339.go new file mode 100644 index 000000000000..760d2dcb0df2 --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/zz_generated_time_rfc3339.go @@ -0,0 +1,85 @@ +//go:build go1.16 +// +build go1.16 + +// 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 armelastic + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "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 +} + +func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { + if t == nil { + return + } else if azcore.IsNullValue(t) { + m[k] = nil + return + } else if reflect.ValueOf(t).IsNil() { + return + } + m[k] = (*timeRFC3339)(t) +} + +func unpopulateTimeRFC3339(data json.RawMessage, t **time.Time) error { + if data == nil || strings.EqualFold(string(data), "null") { + return nil + } + var aux timeRFC3339 + if err := json.Unmarshal(data, &aux); err != nil { + return err + } + *t = (*time.Time)(&aux) + return nil +} diff --git a/sdk/resourcemanager/elastic/armelastic/zz_generated_vmcollection_client.go b/sdk/resourcemanager/elastic/armelastic/zz_generated_vmcollection_client.go new file mode 100644 index 000000000000..6b04a8c39365 --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/zz_generated_vmcollection_client.go @@ -0,0 +1,102 @@ +//go:build go1.16 +// +build go1.16 + +// 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 armelastic + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// VMCollectionClient contains the methods for the VMCollection group. +// Don't use this type directly, use NewVMCollectionClient() instead. +type VMCollectionClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewVMCollectionClient creates a new instance of VMCollectionClient with the specified values. +func NewVMCollectionClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *VMCollectionClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &VMCollectionClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// Update - Update the vm details that will be monitored by the Elastic monitor resource. +// If the operation fails it returns the *ResourceProviderDefaultErrorResponse error type. +func (client *VMCollectionClient) Update(ctx context.Context, resourceGroupName string, monitorName string, options *VMCollectionUpdateOptions) (VMCollectionUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, monitorName, options) + if err != nil { + return VMCollectionUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VMCollectionUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VMCollectionUpdateResponse{}, client.updateHandleError(resp) + } + return VMCollectionUpdateResponse{RawResponse: resp}, nil +} + +// updateCreateRequest creates the Update request. +func (client *VMCollectionClient) updateCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, options *VMCollectionUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/vmCollectionUpdate" + 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 monitorName == "" { + return nil, errors.New("parameter monitorName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + if options != nil && options.Body != nil { + return req, runtime.MarshalAsJSON(req, *options.Body) + } + return req, nil +} + +// updateHandleError handles the Update error response. +func (client *VMCollectionClient) updateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ResourceProviderDefaultErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/elastic/armelastic/zz_generated_vmhost_client.go b/sdk/resourcemanager/elastic/armelastic/zz_generated_vmhost_client.go new file mode 100644 index 000000000000..7437cc581d0b --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/zz_generated_vmhost_client.go @@ -0,0 +1,105 @@ +//go:build go1.16 +// +build go1.16 + +// 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 armelastic + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// VMHostClient contains the methods for the VMHost group. +// Don't use this type directly, use NewVMHostClient() instead. +type VMHostClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewVMHostClient creates a new instance of VMHostClient with the specified values. +func NewVMHostClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *VMHostClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &VMHostClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// List - List the vm resources currently being monitored by the Elastic monitor resource. +// If the operation fails it returns the *ResourceProviderDefaultErrorResponse error type. +func (client *VMHostClient) List(resourceGroupName string, monitorName string, options *VMHostListOptions) *VMHostListPager { + return &VMHostListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, monitorName, options) + }, + advancer: func(ctx context.Context, resp VMHostListResponseEnvelope) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.VMHostListResponse.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *VMHostClient) listCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, options *VMHostListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/listVMHost" + 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 monitorName == "" { + return nil, errors.New("parameter monitorName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *VMHostClient) listHandleResponse(resp *http.Response) (VMHostListResponseEnvelope, error) { + result := VMHostListResponseEnvelope{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.VMHostListResponse); err != nil { + return VMHostListResponseEnvelope{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *VMHostClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ResourceProviderDefaultErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/elastic/armelastic/zz_generated_vmingestion_client.go b/sdk/resourcemanager/elastic/armelastic/zz_generated_vmingestion_client.go new file mode 100644 index 000000000000..25860107c110 --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/zz_generated_vmingestion_client.go @@ -0,0 +1,108 @@ +//go:build go1.16 +// +build go1.16 + +// 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 armelastic + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// VMIngestionClient contains the methods for the VMIngestion group. +// Don't use this type directly, use NewVMIngestionClient() instead. +type VMIngestionClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewVMIngestionClient creates a new instance of VMIngestionClient with the specified values. +func NewVMIngestionClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *VMIngestionClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &VMIngestionClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// Details - List the vm ingestion details that will be monitored by the Elastic monitor resource. +// If the operation fails it returns the *ResourceProviderDefaultErrorResponse error type. +func (client *VMIngestionClient) Details(ctx context.Context, resourceGroupName string, monitorName string, options *VMIngestionDetailsOptions) (VMIngestionDetailsResponseEnvelope, error) { + req, err := client.detailsCreateRequest(ctx, resourceGroupName, monitorName, options) + if err != nil { + return VMIngestionDetailsResponseEnvelope{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VMIngestionDetailsResponseEnvelope{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VMIngestionDetailsResponseEnvelope{}, client.detailsHandleError(resp) + } + return client.detailsHandleResponse(resp) +} + +// detailsCreateRequest creates the Details request. +func (client *VMIngestionClient) detailsCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, options *VMIngestionDetailsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Elastic/monitors/{monitorName}/vmIngestionDetails" + 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 monitorName == "" { + return nil, errors.New("parameter monitorName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// detailsHandleResponse handles the Details response. +func (client *VMIngestionClient) detailsHandleResponse(resp *http.Response) (VMIngestionDetailsResponseEnvelope, error) { + result := VMIngestionDetailsResponseEnvelope{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.VMIngestionDetailsResponse); err != nil { + return VMIngestionDetailsResponseEnvelope{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// detailsHandleError handles the Details error response. +func (client *VMIngestionClient) detailsHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ResourceProviderDefaultErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +}