diff --git a/sdk/resourcemanager/dynatrace/armdynatrace/CHANGELOG.md b/sdk/resourcemanager/dynatrace/armdynatrace/CHANGELOG.md new file mode 100644 index 000000000000..894d090e2e02 --- /dev/null +++ b/sdk/resourcemanager/dynatrace/armdynatrace/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (2022-05-10) + +- Init release. \ No newline at end of file diff --git a/sdk/resourcemanager/dynatrace/armdynatrace/LICENSE.txt b/sdk/resourcemanager/dynatrace/armdynatrace/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/dynatrace/armdynatrace/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/dynatrace/armdynatrace/README.md b/sdk/resourcemanager/dynatrace/armdynatrace/README.md new file mode 100644 index 000000000000..8012c89fc789 --- /dev/null +++ b/sdk/resourcemanager/dynatrace/armdynatrace/README.md @@ -0,0 +1,77 @@ +# Azure Dynatrace Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dynatrace/armdynatrace)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dynatrace/armdynatrace) + +The `armdynatrace` module provides operations for working with Azure Dynatrace. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/dynatrace/armdynatrace) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.18 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 Dynatrace module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dynatrace/armdynatrace +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Dynatrace. 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 Dynatrace 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, err := armdynatrace.NewTagRulesClient(, 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{ + ClientOptions: azcore.ClientOptions { + Cloud: cloud.AzureChina, + }, +} +client, err := armdynatrace.NewTagRulesClient(, 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 `Dynatrace` 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/dynatrace/armdynatrace/autorest.md b/sdk/resourcemanager/dynatrace/armdynatrace/autorest.md new file mode 100644 index 000000000000..f60ae65c8912 --- /dev/null +++ b/sdk/resourcemanager/dynatrace/armdynatrace/autorest.md @@ -0,0 +1,13 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/dynatrace/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/dynatrace/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/dynatrace/armdynatrace/build.go b/sdk/resourcemanager/dynatrace/armdynatrace/build.go new file mode 100644 index 000000000000..96a106df1fb5 --- /dev/null +++ b/sdk/resourcemanager/dynatrace/armdynatrace/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/dynatrace/armdynatrace + +package armdynatrace diff --git a/sdk/resourcemanager/dynatrace/armdynatrace/ci.yml b/sdk/resourcemanager/dynatrace/armdynatrace/ci.yml new file mode 100644 index 000000000000..63cb0b603495 --- /dev/null +++ b/sdk/resourcemanager/dynatrace/armdynatrace/ci.yml @@ -0,0 +1,28 @@ +# 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/dynatrace/armdynatrace/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/dynatrace/armdynatrace/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + IncludeRelease: true + ServiceDirectory: 'resourcemanager/dynatrace/armdynatrace' diff --git a/sdk/resourcemanager/dynatrace/armdynatrace/go.mod b/sdk/resourcemanager/dynatrace/armdynatrace/go.mod new file mode 100644 index 000000000000..565e27b31b45 --- /dev/null +++ b/sdk/resourcemanager/dynatrace/armdynatrace/go.mod @@ -0,0 +1,11 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dynatrace/armdynatrace + +go 1.18 + +require github.com/Azure/azure-sdk-for-go/sdk/azcore v0.23.0 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v0.9.1 // indirect + golang.org/x/net v0.0.0-20210610132358-84b48f89b13b // indirect + golang.org/x/text v0.3.6 // indirect +) diff --git a/sdk/resourcemanager/dynatrace/armdynatrace/go.sum b/sdk/resourcemanager/dynatrace/armdynatrace/go.sum new file mode 100644 index 000000000000..a7eaa30576c1 --- /dev/null +++ b/sdk/resourcemanager/dynatrace/armdynatrace/go.sum @@ -0,0 +1,32 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.23.0 h1:D7l5jspkc4kwBYRWoZE4DQnu6LVpLwDsMZjBKS4wZLQ= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.23.0/go.mod h1:w5pDIZuawUmY3Bj4tVx3Xb8KS96ToB0j315w9rqpAg0= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.9.1 h1:sLZ/Y+P/5RRtsXWylBjB5lkgixYfm0MQPiwrSX//JSo= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.9.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/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/dynatrace/armdynatrace/zz_generated_constants.go b/sdk/resourcemanager/dynatrace/armdynatrace/zz_generated_constants.go new file mode 100644 index 000000000000..2c68940444ed --- /dev/null +++ b/sdk/resourcemanager/dynatrace/armdynatrace/zz_generated_constants.go @@ -0,0 +1,402 @@ +//go:build go1.18 +// +build go1.18 + +// 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 armdynatrace + +const ( + moduleName = "armdynatrace" + moduleVersion = "v0.1.0" +) + +// ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. +type ActionType string + +const ( + ActionTypeInternal ActionType = "Internal" +) + +// PossibleActionTypeValues returns the possible values for the ActionType const type. +func PossibleActionTypeValues() []ActionType { + return []ActionType{ + ActionTypeInternal, + } +} + +// AutoUpdateSetting - Update settings of OneAgent. +type AutoUpdateSetting string + +const ( + AutoUpdateSettingDISABLED AutoUpdateSetting = "DISABLED" + AutoUpdateSettingENABLED AutoUpdateSetting = "ENABLED" +) + +// PossibleAutoUpdateSettingValues returns the possible values for the AutoUpdateSetting const type. +func PossibleAutoUpdateSettingValues() []AutoUpdateSetting { + return []AutoUpdateSetting{ + AutoUpdateSettingDISABLED, + AutoUpdateSettingENABLED, + } +} + +// AvailabilityState - The availability state of OneAgent. +type AvailabilityState string + +const ( + AvailabilityStateCRASHED AvailabilityState = "CRASHED" + AvailabilityStateLOST AvailabilityState = "LOST" + AvailabilityStateMONITORED AvailabilityState = "MONITORED" + AvailabilityStatePREMONITORED AvailabilityState = "PRE_MONITORED" + AvailabilityStateSHUTDOWN AvailabilityState = "SHUTDOWN" + AvailabilityStateUNEXPECTEDSHUTDOWN AvailabilityState = "UNEXPECTED_SHUTDOWN" + AvailabilityStateUNKNOWN AvailabilityState = "UNKNOWN" + AvailabilityStateUNMONITORED AvailabilityState = "UNMONITORED" +) + +// PossibleAvailabilityStateValues returns the possible values for the AvailabilityState const type. +func PossibleAvailabilityStateValues() []AvailabilityState { + return []AvailabilityState{ + AvailabilityStateCRASHED, + AvailabilityStateLOST, + AvailabilityStateMONITORED, + AvailabilityStatePREMONITORED, + AvailabilityStateSHUTDOWN, + AvailabilityStateUNEXPECTEDSHUTDOWN, + AvailabilityStateUNKNOWN, + AvailabilityStateUNMONITORED, + } +} + +// 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, + } +} + +// LiftrResourceCategories - Liftr resource category +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, + } +} + +// LogModule - Tells whether log modules are enabled or not +type LogModule string + +const ( + LogModuleDISABLED LogModule = "DISABLED" + LogModuleENABLED LogModule = "ENABLED" +) + +// PossibleLogModuleValues returns the possible values for the LogModule const type. +func PossibleLogModuleValues() []LogModule { + return []LogModule{ + LogModuleDISABLED, + LogModuleENABLED, + } +} + +// ManagedIdentityType - The kind of managed identity assigned to this resource. +type ManagedIdentityType string + +const ( + ManagedIdentityTypeSystemAndUserAssigned ManagedIdentityType = "SystemAndUserAssigned" + ManagedIdentityTypeSystemAssigned ManagedIdentityType = "SystemAssigned" + ManagedIdentityTypeUserAssigned ManagedIdentityType = "UserAssigned" +) + +// PossibleManagedIdentityTypeValues returns the possible values for the ManagedIdentityType const type. +func PossibleManagedIdentityTypeValues() []ManagedIdentityType { + return []ManagedIdentityType{ + ManagedIdentityTypeSystemAndUserAssigned, + ManagedIdentityTypeSystemAssigned, + ManagedIdentityTypeUserAssigned, + } +} + +// MarketplaceSubscriptionStatus - Flag specifying the Marketplace Subscription Status of the resource. If payment is not +// made in time, the resource will go in Suspended state. +type MarketplaceSubscriptionStatus string + +const ( + MarketplaceSubscriptionStatusActive MarketplaceSubscriptionStatus = "Active" + MarketplaceSubscriptionStatusSuspended MarketplaceSubscriptionStatus = "Suspended" +) + +// PossibleMarketplaceSubscriptionStatusValues returns the possible values for the MarketplaceSubscriptionStatus const type. +func PossibleMarketplaceSubscriptionStatusValues() []MarketplaceSubscriptionStatus { + return []MarketplaceSubscriptionStatus{ + MarketplaceSubscriptionStatusActive, + MarketplaceSubscriptionStatusSuspended, + } +} + +// 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, + } +} + +// MonitoringType - The monitoring mode of OneAgent +type MonitoringType string + +const ( + MonitoringTypeCLOUDINFRASTRUCTURE MonitoringType = "CLOUD_INFRASTRUCTURE" + MonitoringTypeFULLSTACK MonitoringType = "FULL_STACK" +) + +// PossibleMonitoringTypeValues returns the possible values for the MonitoringType const type. +func PossibleMonitoringTypeValues() []MonitoringType { + return []MonitoringType{ + MonitoringTypeCLOUDINFRASTRUCTURE, + MonitoringTypeFULLSTACK, + } +} + +// Origin - The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default +// value is "user,system" +type Origin string + +const ( + OriginSystem Origin = "system" + OriginUser Origin = "user" + OriginUserSystem Origin = "user,system" +) + +// PossibleOriginValues returns the possible values for the Origin const type. +func PossibleOriginValues() []Origin { + return []Origin{ + OriginSystem, + OriginUser, + OriginUserSystem, + } +} + +// ProvisioningState - Provisioning state of the monitoring 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, + } +} + +// SSOStatus - Indicates whether SSO is enabled or not +type SSOStatus string + +const ( + SSOStatusDisabled SSOStatus = "Disabled" + SSOStatusEnabled SSOStatus = "Enabled" +) + +// PossibleSSOStatusValues returns the possible values for the SSOStatus const type. +func PossibleSSOStatusValues() []SSOStatus { + return []SSOStatus{ + SSOStatusDisabled, + SSOStatusEnabled, + } +} + +// SendAADLogsStatus - Indicates whether AAD logs are being sent. +type SendAADLogsStatus string + +const ( + SendAADLogsStatusDisabled SendAADLogsStatus = "Disabled" + SendAADLogsStatusEnabled SendAADLogsStatus = "Enabled" +) + +// PossibleSendAADLogsStatusValues returns the possible values for the SendAADLogsStatus const type. +func PossibleSendAADLogsStatusValues() []SendAADLogsStatus { + return []SendAADLogsStatus{ + SendAADLogsStatusDisabled, + SendAADLogsStatusEnabled, + } +} + +// SendActivityLogsStatus - Indicates whether activity logs are being sent. +type SendActivityLogsStatus string + +const ( + SendActivityLogsStatusDisabled SendActivityLogsStatus = "Disabled" + SendActivityLogsStatusEnabled SendActivityLogsStatus = "Enabled" +) + +// PossibleSendActivityLogsStatusValues returns the possible values for the SendActivityLogsStatus const type. +func PossibleSendActivityLogsStatusValues() []SendActivityLogsStatus { + return []SendActivityLogsStatus{ + SendActivityLogsStatusDisabled, + SendActivityLogsStatusEnabled, + } +} + +// SendSubscriptionLogsStatus - Indicates whether subscription logs are being sent. +type SendSubscriptionLogsStatus string + +const ( + SendSubscriptionLogsStatusDisabled SendSubscriptionLogsStatus = "Disabled" + SendSubscriptionLogsStatusEnabled SendSubscriptionLogsStatus = "Enabled" +) + +// PossibleSendSubscriptionLogsStatusValues returns the possible values for the SendSubscriptionLogsStatus const type. +func PossibleSendSubscriptionLogsStatusValues() []SendSubscriptionLogsStatus { + return []SendSubscriptionLogsStatus{ + SendSubscriptionLogsStatusDisabled, + SendSubscriptionLogsStatusEnabled, + } +} + +// SendingLogsStatus - Indicates whether logs are being sent. +type SendingLogsStatus string + +const ( + SendingLogsStatusDisabled SendingLogsStatus = "Disabled" + SendingLogsStatusEnabled SendingLogsStatus = "Enabled" +) + +// PossibleSendingLogsStatusValues returns the possible values for the SendingLogsStatus const type. +func PossibleSendingLogsStatusValues() []SendingLogsStatus { + return []SendingLogsStatus{ + SendingLogsStatusDisabled, + SendingLogsStatusEnabled, + } +} + +// SendingMetricsStatus - Indicates whether metrics are being sent. +type SendingMetricsStatus string + +const ( + SendingMetricsStatusDisabled SendingMetricsStatus = "Disabled" + SendingMetricsStatusEnabled SendingMetricsStatus = "Enabled" +) + +// PossibleSendingMetricsStatusValues returns the possible values for the SendingMetricsStatus const type. +func PossibleSendingMetricsStatusValues() []SendingMetricsStatus { + return []SendingMetricsStatus{ + SendingMetricsStatusDisabled, + SendingMetricsStatusEnabled, + } +} + +// SingleSignOnStates - Various states of the SSO resource +type SingleSignOnStates string + +const ( + SingleSignOnStatesDisable SingleSignOnStates = "Disable" + SingleSignOnStatesEnable SingleSignOnStates = "Enable" + SingleSignOnStatesExisting SingleSignOnStates = "Existing" + SingleSignOnStatesInitial SingleSignOnStates = "Initial" +) + +// PossibleSingleSignOnStatesValues returns the possible values for the SingleSignOnStates const type. +func PossibleSingleSignOnStatesValues() []SingleSignOnStates { + return []SingleSignOnStates{ + SingleSignOnStatesDisable, + SingleSignOnStatesEnable, + SingleSignOnStatesExisting, + SingleSignOnStatesInitial, + } +} + +// 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, + } +} + +// UpdateStatus - The current update status of OneAgent. +type UpdateStatus string + +const ( + UpdateStatusINCOMPATIBLE UpdateStatus = "INCOMPATIBLE" + UpdateStatusOUTDATED UpdateStatus = "OUTDATED" + UpdateStatusSCHEDULED UpdateStatus = "SCHEDULED" + UpdateStatusSUPPRESSED UpdateStatus = "SUPPRESSED" + UpdateStatusUNKNOWN UpdateStatus = "UNKNOWN" + UpdateStatusUP2DATE UpdateStatus = "UP2DATE" + UpdateStatusUPDATEINPROGRESS UpdateStatus = "UPDATE_IN_PROGRESS" + UpdateStatusUPDATEPENDING UpdateStatus = "UPDATE_PENDING" + UpdateStatusUPDATEPROBLEM UpdateStatus = "UPDATE_PROBLEM" +) + +// PossibleUpdateStatusValues returns the possible values for the UpdateStatus const type. +func PossibleUpdateStatusValues() []UpdateStatus { + return []UpdateStatus{ + UpdateStatusINCOMPATIBLE, + UpdateStatusOUTDATED, + UpdateStatusSCHEDULED, + UpdateStatusSUPPRESSED, + UpdateStatusUNKNOWN, + UpdateStatusUP2DATE, + UpdateStatusUPDATEINPROGRESS, + UpdateStatusUPDATEPENDING, + UpdateStatusUPDATEPROBLEM, + } +} diff --git a/sdk/resourcemanager/dynatrace/armdynatrace/zz_generated_models.go b/sdk/resourcemanager/dynatrace/armdynatrace/zz_generated_models.go new file mode 100644 index 000000000000..3e6249fbb411 --- /dev/null +++ b/sdk/resourcemanager/dynatrace/armdynatrace/zz_generated_models.go @@ -0,0 +1,775 @@ +//go:build go1.18 +// +build go1.18 + +// 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 armdynatrace + +import "time" + +// AccountInfo - Dynatrace Account Information +type AccountInfo struct { + // Account Id of the account this environment is linked to + AccountID *string `json:"accountId,omitempty"` + + // Region in which the account is created + RegionID *string `json:"regionId,omitempty"` +} + +// AccountInfoSecure - Dynatrace account API Key +type AccountInfoSecure struct { + // READ-ONLY; API Key of the user account + APIKey *string `json:"apiKey,omitempty" azure:"ro"` + + // READ-ONLY; Account Id of the account this environment is linked to + AccountID *string `json:"accountId,omitempty" azure:"ro"` + + // READ-ONLY; Region in which the account is created + RegionID *string `json:"regionId,omitempty" azure:"ro"` +} + +// AppServiceInfo - Details of App Services having Dynatrace OneAgent installed +type AppServiceInfo struct { + // Update settings of OneAgent. + AutoUpdateSetting *AutoUpdateSetting `json:"autoUpdateSetting,omitempty"` + + // The availability state of OneAgent. + AvailabilityState *AvailabilityState `json:"availabilityState,omitempty"` + + // The name of the host group + HostGroup *string `json:"hostGroup,omitempty"` + + // The name of the host + HostName *string `json:"hostName,omitempty"` + + // Tells whether log modules are enabled or not + LogModule *LogModule `json:"logModule,omitempty"` + + // The monitoring mode of OneAgent + MonitoringType *MonitoringType `json:"monitoringType,omitempty"` + + // App service resource ID + ResourceID *string `json:"resourceId,omitempty"` + + // The current update status of OneAgent. + UpdateStatus *UpdateStatus `json:"updateStatus,omitempty"` + + // Version of the Dynatrace agent installed on the App Service. + Version *string `json:"version,omitempty"` +} + +// AppServiceListResponse - Response of a list App Services Operation. +type AppServiceListResponse struct { + // REQUIRED; The link to the next page of items + NextLink *string `json:"nextLink,omitempty"` + + // REQUIRED; The items on this page + Value []*AppServiceInfo `json:"value,omitempty"` +} + +// EnvironmentInfo - Dynatrace Environment Information +type EnvironmentInfo struct { + // Id of the environment created + EnvironmentID *string `json:"environmentId,omitempty"` + + // Ingestion key of the environment + IngestionKey *string `json:"ingestionKey,omitempty"` + + // Landing URL for Dynatrace environment + LandingURL *string `json:"landingURL,omitempty"` + + // Ingestion endpoint used for sending logs + LogsIngestionEndpoint *string `json:"logsIngestionEndpoint,omitempty"` +} + +// EnvironmentProperties - Properties of the Dynatrace environment. +type EnvironmentProperties struct { + // Dynatrace Account Information + AccountInfo *AccountInfo `json:"accountInfo,omitempty"` + + // Dynatrace Environment Information + EnvironmentInfo *EnvironmentInfo `json:"environmentInfo,omitempty"` + + // The details of a Dynatrace single sign-on. + SingleSignOnProperties *SingleSignOnProperties `json:"singleSignOnProperties,omitempty"` + + // User id + UserID *string `json:"userId,omitempty"` +} + +// ErrorAdditionalInfo - The resource management error additional info. +type ErrorAdditionalInfo struct { + // READ-ONLY; The additional info. + Info interface{} `json:"info,omitempty" azure:"ro"` + + // READ-ONLY; The additional info type. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// ErrorDetail - The error detail. +type ErrorDetail struct { + // READ-ONLY; The error additional info. + AdditionalInfo []*ErrorAdditionalInfo `json:"additionalInfo,omitempty" azure:"ro"` + + // READ-ONLY; The error code. + Code *string `json:"code,omitempty" azure:"ro"` + + // READ-ONLY; The error details. + Details []*ErrorDetail `json:"details,omitempty" azure:"ro"` + + // READ-ONLY; The error message. + Message *string `json:"message,omitempty" azure:"ro"` + + // READ-ONLY; The error target. + Target *string `json:"target,omitempty" azure:"ro"` +} + +// ErrorResponse - Common error response for all Azure Resource Manager APIs to return error details for failed operations. +// (This also follows the OData error response format.). +type ErrorResponse struct { + // The error object. + Error *ErrorDetail `json:"error,omitempty"` +} + +// 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. Exclusion takes priority over inclusion. + 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 - The properties of the managed service identities assigned to this resource. +type IdentityProperties struct { + // REQUIRED; The type of managed identity assigned to this resource. + Type *ManagedIdentityType `json:"type,omitempty"` + + // The identities assigned to this resource by the user. + UserAssignedIdentities map[string]*UserAssignedIdentity `json:"userAssignedIdentities,omitempty"` + + // READ-ONLY; The active directory identifier of this principal. + PrincipalID *string `json:"principalId,omitempty" azure:"ro"` + + // READ-ONLY; The Active Directory tenant id of the principal. + TenantID *string `json:"tenantId,omitempty" azure:"ro"` +} + +// LinkableEnvironmentListResponse - Response for getting all the linkable environments +type LinkableEnvironmentListResponse struct { + // Link to the next set of results, if any. + NextLink *string `json:"nextLink,omitempty"` + + // List of environments for which user is an admin + Value []*LinkableEnvironmentResponse `json:"value,omitempty"` +} + +// LinkableEnvironmentRequest - Request for getting all the linkable environments for a user +type LinkableEnvironmentRequest struct { + // Azure region in which we want to link the environment + Region *string `json:"region,omitempty"` + + // Tenant Id of the user in which they want to link the environment + TenantID *string `json:"tenantId,omitempty"` + + // user principal id of the user + UserPrincipal *string `json:"userPrincipal,omitempty"` +} + +// LinkableEnvironmentResponse - Response for getting all the linkable environments +type LinkableEnvironmentResponse struct { + // environment id for which user is an admin + EnvironmentID *string `json:"environmentId,omitempty"` + + // Name of the environment + EnvironmentName *string `json:"environmentName,omitempty"` + + // Billing plan information. + PlanData *PlanData `json:"planData,omitempty"` +} + +// 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 *SendAADLogsStatus `json:"sendAadLogs,omitempty"` + + // Flag specifying if activity logs from Azure resources should be sent for the Monitor resource. + SendActivityLogs *SendActivityLogsStatus `json:"sendActivityLogs,omitempty"` + + // Flag specifying if subscription logs should be sent for the Monitor resource. + SendSubscriptionLogs *SendSubscriptionLogsStatus `json:"sendSubscriptionLogs,omitempty"` +} + +// MetricRules - Set of rules for sending metrics for the Monitor resource. +type MetricRules struct { + // List of filtering tags to be used for capturing metrics. 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"` +} + +// MonitorProperties - Properties specific to the monitor resource. +type MonitorProperties struct { + // Properties of the Dynatrace environment. + DynatraceEnvironmentProperties *EnvironmentProperties `json:"dynatraceEnvironmentProperties,omitempty"` + + // Marketplace subscription status. + MarketplaceSubscriptionStatus *MarketplaceSubscriptionStatus `json:"marketplaceSubscriptionStatus,omitempty"` + + // Status of the monitor. + MonitoringStatus *MonitoringStatus `json:"monitoringStatus,omitempty"` + + // Billing plan information. + PlanData *PlanData `json:"planData,omitempty"` + + // User info. + UserInfo *UserInfo `json:"userInfo,omitempty"` + + // READ-ONLY; Liftr Resource category. + LiftrResourceCategory *LiftrResourceCategories `json:"liftrResourceCategory,omitempty" azure:"ro"` + + // READ-ONLY; The priority of the resource. + LiftrResourcePreference *int32 `json:"liftrResourcePreference,omitempty" azure:"ro"` + + // READ-ONLY; Provisioning state of the resource. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// MonitorResource - Dynatrace Monitor Resource +type MonitorResource struct { + // REQUIRED; The geo-location where the resource lives + Location *string `json:"location,omitempty"` + + // REQUIRED; The resource-specific properties for this resource. + Properties *MonitorProperties `json:"properties,omitempty"` + + // The managed service identities assigned to this resource. + Identity *IdentityProperties `json:"identity,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; System metadata for this resource. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// MonitorResourceListResult - The response of a MonitorResource list operation. +type MonitorResourceListResult struct { + // REQUIRED; The link to the next page of items + NextLink *string `json:"nextLink,omitempty"` + + // REQUIRED; The items on this page + Value []*MonitorResource `json:"value,omitempty"` +} + +// MonitorResourceUpdate - The updatable properties of the MonitorResource. +type MonitorResourceUpdate struct { + // Properties of the Dynatrace environment. + DynatraceEnvironmentProperties *EnvironmentProperties `json:"dynatraceEnvironmentProperties,omitempty"` + + // Marketplace subscription status. + MarketplaceSubscriptionStatus *MarketplaceSubscriptionStatus `json:"marketplaceSubscriptionStatus,omitempty"` + + // Status of the monitor. + MonitoringStatus *MonitoringStatus `json:"monitoringStatus,omitempty"` + + // Billing plan information. + PlanData *PlanData `json:"planData,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` + + // User info. + UserInfo *UserInfo `json:"userInfo,omitempty"` +} + +// MonitoredResource - Details of resource being monitored by Dynatrace 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"` + + // Reason for why the resource is sending metrics (or why it is not sending). + ReasonForMetricsStatus *string `json:"reasonForMetricsStatus,omitempty"` + + // Flag indicating if resource is sending logs to Dynatrace. + SendingLogs *SendingLogsStatus `json:"sendingLogs,omitempty"` + + // Flag indicating if resource is sending metrics to Dynatrace. + SendingMetrics *SendingMetricsStatus `json:"sendingMetrics,omitempty"` +} + +// MonitoredResourceListResponse - List of all the resources being monitored by Dynatrace monitor resource +type MonitoredResourceListResponse struct { + // REQUIRED; The link to the next page of items + NextLink *string `json:"nextLink,omitempty"` + + // REQUIRED; The items on this page + Value []*MonitoredResource `json:"value,omitempty"` +} + +// MonitoringTagRulesProperties - Properties for the Tag rules resource of a Monitor account. +type MonitoringTagRulesProperties struct { + // Set of rules for sending logs for the Monitor resource. + LogRules *LogRules `json:"logRules,omitempty"` + + // Set of rules for sending metrics for the Monitor resource. + MetricRules *MetricRules `json:"metricRules,omitempty"` + + // READ-ONLY; Provisioning state of the resource. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// MonitorsClientBeginCreateOrUpdateOptions contains the optional parameters for the MonitorsClient.BeginCreateOrUpdate method. +type MonitorsClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// MonitorsClientBeginDeleteOptions contains the optional parameters for the MonitorsClient.BeginDelete method. +type MonitorsClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// MonitorsClientGetAccountCredentialsOptions contains the optional parameters for the MonitorsClient.GetAccountCredentials +// method. +type MonitorsClientGetAccountCredentialsOptions struct { + // placeholder for future optional parameters +} + +// MonitorsClientGetOptions contains the optional parameters for the MonitorsClient.Get method. +type MonitorsClientGetOptions struct { + // placeholder for future optional parameters +} + +// MonitorsClientGetSSODetailsOptions contains the optional parameters for the MonitorsClient.GetSSODetails method. +type MonitorsClientGetSSODetailsOptions struct { + // The details of the get sso details request. + Request *SSODetailsRequest +} + +// MonitorsClientGetVMHostPayloadOptions contains the optional parameters for the MonitorsClient.GetVMHostPayload method. +type MonitorsClientGetVMHostPayloadOptions struct { + // placeholder for future optional parameters +} + +// MonitorsClientListAppServicesOptions contains the optional parameters for the MonitorsClient.ListAppServices method. +type MonitorsClientListAppServicesOptions struct { + // placeholder for future optional parameters +} + +// MonitorsClientListByResourceGroupOptions contains the optional parameters for the MonitorsClient.ListByResourceGroup method. +type MonitorsClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// MonitorsClientListBySubscriptionIDOptions contains the optional parameters for the MonitorsClient.ListBySubscriptionID +// method. +type MonitorsClientListBySubscriptionIDOptions struct { + // placeholder for future optional parameters +} + +// MonitorsClientListHostsOptions contains the optional parameters for the MonitorsClient.ListHosts method. +type MonitorsClientListHostsOptions struct { + // placeholder for future optional parameters +} + +// MonitorsClientListLinkableEnvironmentsOptions contains the optional parameters for the MonitorsClient.ListLinkableEnvironments +// method. +type MonitorsClientListLinkableEnvironmentsOptions struct { + // placeholder for future optional parameters +} + +// MonitorsClientListMonitoredResourcesOptions contains the optional parameters for the MonitorsClient.ListMonitoredResources +// method. +type MonitorsClientListMonitoredResourcesOptions struct { + // placeholder for future optional parameters +} + +// MonitorsClientUpdateOptions contains the optional parameters for the MonitorsClient.Update method. +type MonitorsClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// Operation - Details of a REST API operation, returned from the Resource Provider Operations API +type Operation struct { + // Localized display information for this particular operation. + Display *OperationDisplay `json:"display,omitempty"` + + // READ-ONLY; Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + ActionType *ActionType `json:"actionType,omitempty" azure:"ro"` + + // READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for ARM/control-plane + // operations. + IsDataAction *bool `json:"isDataAction,omitempty" azure:"ro"` + + // READ-ONLY; The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", + // "Microsoft.Compute/virtualMachines/capture/action" + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default + // value is "user,system" + Origin *Origin `json:"origin,omitempty" azure:"ro"` +} + +// OperationDisplay - Localized display information for this particular operation. +type OperationDisplay struct { + // READ-ONLY; The short, localized friendly description of the operation; suitable for tool tips and detailed views. + Description *string `json:"description,omitempty" azure:"ro"` + + // READ-ONLY; The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual + // Machine", "Restart Virtual Machine". + Operation *string `json:"operation,omitempty" azure:"ro"` + + // READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft + // Compute". + Provider *string `json:"provider,omitempty" azure:"ro"` + + // READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job + // Schedule Collections". + Resource *string `json:"resource,omitempty" azure:"ro"` +} + +// OperationListResult - A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to +// get the next set of results. +type OperationListResult struct { + // READ-ONLY; URL to get the next set of operation list results (if there are any). + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; List of operations supported by the resource provider + Value []*Operation `json:"value,omitempty" azure:"ro"` +} + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} + +// PlanData - Billing plan information. +type PlanData struct { + // different billing cycles like MONTHLY/WEEKLY. this could be enum + BillingCycle *string `json:"billingCycle,omitempty"` + + // date when plan was applied + EffectiveDate *time.Time `json:"effectiveDate,omitempty"` + + // plan id as published by Dynatrace + PlanDetails *string `json:"planDetails,omitempty"` + + // different usage type like PAYG/COMMITTED. this could be enum + UsageType *string `json:"usageType,omitempty"` +} + +// ProxyResource - The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a +// location +type ProxyResource struct { + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// Resource - Common fields that are returned in the response for all Azure Resource Manager resources +type Resource struct { + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// SSODetailsRequest - Request for getting sso details for a user +type SSODetailsRequest struct { + // user principal id of the user + UserPrincipal *string `json:"userPrincipal,omitempty"` +} + +// SSODetailsResponse - SSO details from the Dynatrace partner +type SSODetailsResponse struct { + // array of Aad(azure active directory) domains + AADDomains []*string `json:"aadDomains,omitempty"` + + // Array of admin user emails. + AdminUsers []*string `json:"adminUsers,omitempty"` + + // Whether the SSO is enabled for this resource or not. + IsSsoEnabled *SSOStatus `json:"isSsoEnabled,omitempty"` + + // URL for Azure AD metadata + MetadataURL *string `json:"metadataUrl,omitempty"` + + // The login URL specific to this Dynatrace Environment + SingleSignOnURL *string `json:"singleSignOnUrl,omitempty"` +} + +// SingleSignOnClientBeginCreateOrUpdateOptions contains the optional parameters for the SingleSignOnClient.BeginCreateOrUpdate +// method. +type SingleSignOnClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// SingleSignOnClientGetOptions contains the optional parameters for the SingleSignOnClient.Get method. +type SingleSignOnClientGetOptions struct { + // placeholder for future optional parameters +} + +// SingleSignOnClientListOptions contains the optional parameters for the SingleSignOnClient.List method. +type SingleSignOnClientListOptions struct { + // placeholder for future optional parameters +} + +// SingleSignOnProperties - The details of a Dynatrace single sign-on. +type SingleSignOnProperties struct { + // array of Aad(azure active directory) domains + AADDomains []*string `json:"aadDomains,omitempty"` + + // Version of the Dynatrace agent installed on the VM. + EnterpriseAppID *string `json:"enterpriseAppId,omitempty"` + + // State of Single Sign On + SingleSignOnState *SingleSignOnStates `json:"singleSignOnState,omitempty"` + + // The login URL specific to this Dynatrace Environment + SingleSignOnURL *string `json:"singleSignOnUrl,omitempty"` + + // READ-ONLY; Provisioning state of the resource. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// SingleSignOnResource - Single sign-on configurations for a given monitor resource. +type SingleSignOnResource struct { + // REQUIRED; The resource-specific properties for this resource. + Properties *SingleSignOnProperties `json:"properties,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; System metadata for this resource. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// SingleSignOnResourceListResult - The response of a DynatraceSingleSignOnResource list operation. +type SingleSignOnResourceListResult struct { + // REQUIRED; The link to the next page of items + NextLink *string `json:"nextLink,omitempty"` + + // REQUIRED; The items on this page + Value []*SingleSignOnResource `json:"value,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"` +} + +// TagRule - Tag rules for a monitor resource +type TagRule struct { + // REQUIRED; The resource-specific properties for this resource. + Properties *MonitoringTagRulesProperties `json:"properties,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; System metadata for this resource. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// TagRuleListResult - The response of a TagRule list operation. +type TagRuleListResult struct { + // REQUIRED; The link to the next page of items + NextLink *string `json:"nextLink,omitempty"` + + // REQUIRED; The items on this page + Value []*TagRule `json:"value,omitempty"` +} + +// TagRuleUpdate - The updatable properties of the TagRule. +type TagRuleUpdate struct { + // Set of rules for sending logs for the Monitor resource. + LogRules *LogRules `json:"logRules,omitempty"` + + // Set of rules for sending metrics for the Monitor resource. + MetricRules *MetricRules `json:"metricRules,omitempty"` +} + +// TagRulesClientBeginCreateOrUpdateOptions contains the optional parameters for the TagRulesClient.BeginCreateOrUpdate method. +type TagRulesClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// TagRulesClientBeginDeleteOptions contains the optional parameters for the TagRulesClient.BeginDelete method. +type TagRulesClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// TagRulesClientGetOptions contains the optional parameters for the TagRulesClient.Get method. +type TagRulesClientGetOptions struct { + // placeholder for future optional parameters +} + +// TagRulesClientListOptions contains the optional parameters for the TagRulesClient.List method. +type TagRulesClientListOptions struct { + // placeholder for future optional parameters +} + +// TagRulesClientUpdateOptions contains the optional parameters for the TagRulesClient.Update method. +type TagRulesClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// TrackedResource - The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' +// and a 'location' +type TrackedResource struct { + // REQUIRED; The geo-location where the resource lives + Location *string `json:"location,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// UserAssignedIdentity - A managed identity assigned by the user. +type UserAssignedIdentity struct { + // REQUIRED; The active directory client identifier for this principal. + ClientID *string `json:"clientId,omitempty"` + + // REQUIRED; The active directory identifier for this principal. + PrincipalID *string `json:"principalId,omitempty"` +} + +// UserInfo - User info. +type UserInfo struct { + // Country of the user + Country *string `json:"country,omitempty"` + + // Email of the user used by Dynatrace 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"` + + // Phone number of the user used by Dynatrace for contacting them if needed + PhoneNumber *string `json:"phoneNumber,omitempty"` +} + +// VMExtensionPayload - Response of payload to be passed while installing VM agent. +type VMExtensionPayload struct { + // Id of the environment created + EnvironmentID *string `json:"environmentId,omitempty"` + + // Ingestion key of the environment + IngestionKey *string `json:"ingestionKey,omitempty"` +} + +// VMHostsListResponse - Response of a list VM Host Operation. +type VMHostsListResponse struct { + // REQUIRED; The link to the next page of items + NextLink *string `json:"nextLink,omitempty"` + + // REQUIRED; The items on this page + Value []*VMInfo `json:"value,omitempty"` +} + +// VMInfo - Details of VM Resource having Dynatrace OneAgent installed +type VMInfo struct { + // Update settings of OneAgent. + AutoUpdateSetting *AutoUpdateSetting `json:"autoUpdateSetting,omitempty"` + + // The availability state of OneAgent. + AvailabilityState *AvailabilityState `json:"availabilityState,omitempty"` + + // The name of the host group + HostGroup *string `json:"hostGroup,omitempty"` + + // The name of the host + HostName *string `json:"hostName,omitempty"` + + // Tells whether log modules are enabled or not + LogModule *LogModule `json:"logModule,omitempty"` + + // The monitoring mode of OneAgent + MonitoringType *MonitoringType `json:"monitoringType,omitempty"` + + // Azure VM resource ID + ResourceID *string `json:"resourceId,omitempty"` + + // The current update status of OneAgent. + UpdateStatus *UpdateStatus `json:"updateStatus,omitempty"` + + // Version of the Dynatrace agent installed on the VM. + Version *string `json:"version,omitempty"` +} diff --git a/sdk/resourcemanager/dynatrace/armdynatrace/zz_generated_models_serde.go b/sdk/resourcemanager/dynatrace/armdynatrace/zz_generated_models_serde.go new file mode 100644 index 000000000000..18dced3e8b06 --- /dev/null +++ b/sdk/resourcemanager/dynatrace/armdynatrace/zz_generated_models_serde.go @@ -0,0 +1,287 @@ +//go:build go1.18 +// +build go1.18 + +// 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 armdynatrace + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type AppServiceListResponse. +func (a AppServiceListResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorDetail. +func (e ErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "additionalInfo", e.AdditionalInfo) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + populate(objectMap, "target", e.Target) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type IdentityProperties. +func (i IdentityProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "principalId", i.PrincipalID) + populate(objectMap, "tenantId", i.TenantID) + populate(objectMap, "type", i.Type) + populate(objectMap, "userAssignedIdentities", i.UserAssignedIdentities) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type LinkableEnvironmentListResponse. +func (l LinkableEnvironmentListResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", l.NextLink) + populate(objectMap, "value", l.Value) + return json.Marshal(objectMap) +} + +// 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) +} + +// MarshalJSON implements the json.Marshaller interface for type MetricRules. +func (m MetricRules) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "filteringTags", m.FilteringTags) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type MonitorResource. +func (m MonitorResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", m.ID) + populate(objectMap, "identity", m.Identity) + populate(objectMap, "location", m.Location) + populate(objectMap, "name", m.Name) + populate(objectMap, "properties", m.Properties) + populate(objectMap, "systemData", m.SystemData) + populate(objectMap, "tags", m.Tags) + populate(objectMap, "type", m.Type) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type MonitorResourceListResult. +func (m MonitorResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", m.NextLink) + populate(objectMap, "value", m.Value) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type MonitorResourceUpdate. +func (m MonitorResourceUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "dynatraceEnvironmentProperties", m.DynatraceEnvironmentProperties) + populate(objectMap, "marketplaceSubscriptionStatus", m.MarketplaceSubscriptionStatus) + populate(objectMap, "monitoringStatus", m.MonitoringStatus) + populate(objectMap, "planData", m.PlanData) + populate(objectMap, "tags", m.Tags) + populate(objectMap, "userInfo", m.UserInfo) + return json.Marshal(objectMap) +} + +// 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) +} + +// 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) +} + +// MarshalJSON implements the json.Marshaller interface for type PlanData. +func (p PlanData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "billingCycle", p.BillingCycle) + populateTimeRFC3339(objectMap, "effectiveDate", p.EffectiveDate) + populate(objectMap, "planDetails", p.PlanDetails) + populate(objectMap, "usageType", p.UsageType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PlanData. +func (p *PlanData) 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 "billingCycle": + err = unpopulate(val, &p.BillingCycle) + delete(rawMsg, key) + case "effectiveDate": + err = unpopulateTimeRFC3339(val, &p.EffectiveDate) + delete(rawMsg, key) + case "planDetails": + err = unpopulate(val, &p.PlanDetails) + delete(rawMsg, key) + case "usageType": + err = unpopulate(val, &p.UsageType) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SSODetailsResponse. +func (s SSODetailsResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "aadDomains", s.AADDomains) + populate(objectMap, "adminUsers", s.AdminUsers) + populate(objectMap, "isSsoEnabled", s.IsSsoEnabled) + populate(objectMap, "metadataUrl", s.MetadataURL) + populate(objectMap, "singleSignOnUrl", s.SingleSignOnURL) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type SingleSignOnProperties. +func (s SingleSignOnProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "aadDomains", s.AADDomains) + populate(objectMap, "enterpriseAppId", s.EnterpriseAppID) + populate(objectMap, "provisioningState", s.ProvisioningState) + populate(objectMap, "singleSignOnState", s.SingleSignOnState) + populate(objectMap, "singleSignOnUrl", s.SingleSignOnURL) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type SingleSignOnResourceListResult. +func (s SingleSignOnResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// 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 +} + +// MarshalJSON implements the json.Marshaller interface for type TagRuleListResult. +func (t TagRuleListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", t.NextLink) + populate(objectMap, "value", t.Value) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type TagRuleUpdate. +func (t TagRuleUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "logRules", t.LogRules) + populate(objectMap, "metricRules", t.MetricRules) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type TrackedResource. +func (t TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", t.ID) + populate(objectMap, "location", t.Location) + populate(objectMap, "name", t.Name) + populate(objectMap, "tags", t.Tags) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type VMHostsListResponse. +func (v VMHostsListResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", v.NextLink) + populate(objectMap, "value", v.Value) + return json.Marshal(objectMap) +} + +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/dynatrace/armdynatrace/zz_generated_monitors_client.go b/sdk/resourcemanager/dynatrace/armdynatrace/zz_generated_monitors_client.go new file mode 100644 index 000000000000..6a8215158ad6 --- /dev/null +++ b/sdk/resourcemanager/dynatrace/armdynatrace/zz_generated_monitors_client.go @@ -0,0 +1,862 @@ +//go:build go1.18 +// +build go1.18 + +// 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 armdynatrace + +import ( + "context" + "errors" + "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/cloud" + "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 { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewMonitorsClient creates a new instance of MonitorsClient with the specified values. +// subscriptionID - The ID of the target subscription. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewMonitorsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*MonitorsClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublicCloud.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &MonitorsClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// BeginCreateOrUpdate - Create a MonitorResource +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. The name is case insensitive. +// monitorName - Monitor resource name +// resource - Resource create parameters. +// options - MonitorsClientBeginCreateOrUpdateOptions contains the optional parameters for the MonitorsClient.BeginCreateOrUpdate +// method. +func (client *MonitorsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, monitorName string, resource MonitorResource, options *MonitorsClientBeginCreateOrUpdateOptions) (*armruntime.Poller[MonitorsClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, monitorName, resource, options) + if err != nil { + return nil, err + } + return armruntime.NewPoller(resp, client.pl, &armruntime.NewPollerOptions[MonitorsClientCreateOrUpdateResponse]{ + FinalStateVia: armruntime.FinalStateViaAzureAsyncOp, + }) + } else { + return armruntime.NewPollerFromResumeToken[MonitorsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// CreateOrUpdate - Create a MonitorResource +// If the operation fails it returns an *azcore.ResponseError type. +func (client *MonitorsClient) createOrUpdate(ctx context.Context, resourceGroupName string, monitorName string, resource MonitorResource, options *MonitorsClientBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, monitorName, resource, 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, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *MonitorsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, resource MonitorResource, options *MonitorsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Dynatrace.Observability/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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, resource) +} + +// BeginDelete - Delete a MonitorResource +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. The name is case insensitive. +// monitorName - Monitor resource name +// options - MonitorsClientBeginDeleteOptions contains the optional parameters for the MonitorsClient.BeginDelete method. +func (client *MonitorsClient) BeginDelete(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsClientBeginDeleteOptions) (*armruntime.Poller[MonitorsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, monitorName, options) + if err != nil { + return nil, err + } + return armruntime.NewPoller(resp, client.pl, &armruntime.NewPollerOptions[MonitorsClientDeleteResponse]{ + FinalStateVia: armruntime.FinalStateViaAzureAsyncOp, + }) + } else { + return armruntime.NewPollerFromResumeToken[MonitorsClientDeleteResponse](options.ResumeToken, client.pl, nil) + } +} + +// Delete - Delete a MonitorResource +// If the operation fails it returns an *azcore.ResponseError type. +func (client *MonitorsClient) deleteOperation(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsClientBeginDeleteOptions) (*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, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *MonitorsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Dynatrace.Observability/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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// Get - Get a MonitorResource +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. The name is case insensitive. +// monitorName - Monitor resource name +// options - MonitorsClientGetOptions contains the optional parameters for the MonitorsClient.Get method. +func (client *MonitorsClient) Get(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsClientGetOptions) (MonitorsClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, monitorName, options) + if err != nil { + return MonitorsClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return MonitorsClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return MonitorsClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *MonitorsClient) getCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Dynatrace.Observability/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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01-preview") + 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) (MonitorsClientGetResponse, error) { + result := MonitorsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.MonitorResource); err != nil { + return MonitorsClientGetResponse{}, err + } + return result, nil +} + +// GetAccountCredentials - Gets the user account credentials for a Monitor +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. The name is case insensitive. +// monitorName - Monitor resource name +// options - MonitorsClientGetAccountCredentialsOptions contains the optional parameters for the MonitorsClient.GetAccountCredentials +// method. +func (client *MonitorsClient) GetAccountCredentials(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsClientGetAccountCredentialsOptions) (MonitorsClientGetAccountCredentialsResponse, error) { + req, err := client.getAccountCredentialsCreateRequest(ctx, resourceGroupName, monitorName, options) + if err != nil { + return MonitorsClientGetAccountCredentialsResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return MonitorsClientGetAccountCredentialsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return MonitorsClientGetAccountCredentialsResponse{}, runtime.NewResponseError(resp) + } + return client.getAccountCredentialsHandleResponse(resp) +} + +// getAccountCredentialsCreateRequest creates the GetAccountCredentials request. +func (client *MonitorsClient) getAccountCredentialsCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsClientGetAccountCredentialsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Dynatrace.Observability/monitors/{monitorName}/getAccountCredentials" + 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getAccountCredentialsHandleResponse handles the GetAccountCredentials response. +func (client *MonitorsClient) getAccountCredentialsHandleResponse(resp *http.Response) (MonitorsClientGetAccountCredentialsResponse, error) { + result := MonitorsClientGetAccountCredentialsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AccountInfoSecure); err != nil { + return MonitorsClientGetAccountCredentialsResponse{}, err + } + return result, nil +} + +// GetSSODetails - Gets the SSO configuration details from the partner. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. The name is case insensitive. +// monitorName - Monitor resource name +// options - MonitorsClientGetSSODetailsOptions contains the optional parameters for the MonitorsClient.GetSSODetails method. +func (client *MonitorsClient) GetSSODetails(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsClientGetSSODetailsOptions) (MonitorsClientGetSSODetailsResponse, error) { + req, err := client.getSSODetailsCreateRequest(ctx, resourceGroupName, monitorName, options) + if err != nil { + return MonitorsClientGetSSODetailsResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return MonitorsClientGetSSODetailsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return MonitorsClientGetSSODetailsResponse{}, runtime.NewResponseError(resp) + } + return client.getSSODetailsHandleResponse(resp) +} + +// getSSODetailsCreateRequest creates the GetSSODetails request. +func (client *MonitorsClient) getSSODetailsCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsClientGetSSODetailsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Dynatrace.Observability/monitors/{monitorName}/getSSODetails" + 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + if options != nil && options.Request != nil { + return req, runtime.MarshalAsJSON(req, *options.Request) + } + return req, nil +} + +// getSSODetailsHandleResponse handles the GetSSODetails response. +func (client *MonitorsClient) getSSODetailsHandleResponse(resp *http.Response) (MonitorsClientGetSSODetailsResponse, error) { + result := MonitorsClientGetSSODetailsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SSODetailsResponse); err != nil { + return MonitorsClientGetSSODetailsResponse{}, err + } + return result, nil +} + +// GetVMHostPayload - Returns the payload that needs to be passed in the request body for installing Dynatrace agent on a +// VM. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. The name is case insensitive. +// monitorName - Monitor resource name +// options - MonitorsClientGetVMHostPayloadOptions contains the optional parameters for the MonitorsClient.GetVMHostPayload +// method. +func (client *MonitorsClient) GetVMHostPayload(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsClientGetVMHostPayloadOptions) (MonitorsClientGetVMHostPayloadResponse, error) { + req, err := client.getVMHostPayloadCreateRequest(ctx, resourceGroupName, monitorName, options) + if err != nil { + return MonitorsClientGetVMHostPayloadResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return MonitorsClientGetVMHostPayloadResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return MonitorsClientGetVMHostPayloadResponse{}, runtime.NewResponseError(resp) + } + return client.getVMHostPayloadHandleResponse(resp) +} + +// getVMHostPayloadCreateRequest creates the GetVMHostPayload request. +func (client *MonitorsClient) getVMHostPayloadCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsClientGetVMHostPayloadOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Dynatrace.Observability/monitors/{monitorName}/getVMHostPayload" + 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getVMHostPayloadHandleResponse handles the GetVMHostPayload response. +func (client *MonitorsClient) getVMHostPayloadHandleResponse(resp *http.Response) (MonitorsClientGetVMHostPayloadResponse, error) { + result := MonitorsClientGetVMHostPayloadResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.VMExtensionPayload); err != nil { + return MonitorsClientGetVMHostPayloadResponse{}, err + } + return result, nil +} + +// NewListAppServicesPager - Gets list of App Services with Dynatrace PaaS OneAgent enabled +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. The name is case insensitive. +// monitorName - Monitor resource name +// options - MonitorsClientListAppServicesOptions contains the optional parameters for the MonitorsClient.ListAppServices +// method. +func (client *MonitorsClient) NewListAppServicesPager(resourceGroupName string, monitorName string, options *MonitorsClientListAppServicesOptions) *runtime.Pager[MonitorsClientListAppServicesResponse] { + return runtime.NewPager(runtime.PageProcessor[MonitorsClientListAppServicesResponse]{ + More: func(page MonitorsClientListAppServicesResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *MonitorsClientListAppServicesResponse) (MonitorsClientListAppServicesResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listAppServicesCreateRequest(ctx, resourceGroupName, monitorName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return MonitorsClientListAppServicesResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return MonitorsClientListAppServicesResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return MonitorsClientListAppServicesResponse{}, runtime.NewResponseError(resp) + } + return client.listAppServicesHandleResponse(resp) + }, + }) +} + +// listAppServicesCreateRequest creates the ListAppServices request. +func (client *MonitorsClient) listAppServicesCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsClientListAppServicesOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Dynatrace.Observability/monitors/{monitorName}/listAppServices" + 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listAppServicesHandleResponse handles the ListAppServices response. +func (client *MonitorsClient) listAppServicesHandleResponse(resp *http.Response) (MonitorsClientListAppServicesResponse, error) { + result := MonitorsClientListAppServicesResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AppServiceListResponse); err != nil { + return MonitorsClientListAppServicesResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - List MonitorResource resources by resource group +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. The name is case insensitive. +// options - MonitorsClientListByResourceGroupOptions contains the optional parameters for the MonitorsClient.ListByResourceGroup +// method. +func (client *MonitorsClient) NewListByResourceGroupPager(resourceGroupName string, options *MonitorsClientListByResourceGroupOptions) *runtime.Pager[MonitorsClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PageProcessor[MonitorsClientListByResourceGroupResponse]{ + More: func(page MonitorsClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *MonitorsClientListByResourceGroupResponse) (MonitorsClientListByResourceGroupResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return MonitorsClientListByResourceGroupResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return MonitorsClientListByResourceGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return MonitorsClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listByResourceGroupHandleResponse(resp) + }, + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *MonitorsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *MonitorsClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Dynatrace.Observability/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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01-preview") + 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) (MonitorsClientListByResourceGroupResponse, error) { + result := MonitorsClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.MonitorResourceListResult); err != nil { + return MonitorsClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionIDPager - List all MonitorResource by subscriptionId +// If the operation fails it returns an *azcore.ResponseError type. +// options - MonitorsClientListBySubscriptionIDOptions contains the optional parameters for the MonitorsClient.ListBySubscriptionID +// method. +func (client *MonitorsClient) NewListBySubscriptionIDPager(options *MonitorsClientListBySubscriptionIDOptions) *runtime.Pager[MonitorsClientListBySubscriptionIDResponse] { + return runtime.NewPager(runtime.PageProcessor[MonitorsClientListBySubscriptionIDResponse]{ + More: func(page MonitorsClientListBySubscriptionIDResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *MonitorsClientListBySubscriptionIDResponse) (MonitorsClientListBySubscriptionIDResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listBySubscriptionIDCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return MonitorsClientListBySubscriptionIDResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return MonitorsClientListBySubscriptionIDResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return MonitorsClientListBySubscriptionIDResponse{}, runtime.NewResponseError(resp) + } + return client.listBySubscriptionIDHandleResponse(resp) + }, + }) +} + +// listBySubscriptionIDCreateRequest creates the ListBySubscriptionID request. +func (client *MonitorsClient) listBySubscriptionIDCreateRequest(ctx context.Context, options *MonitorsClientListBySubscriptionIDOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Dynatrace.Observability/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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listBySubscriptionIDHandleResponse handles the ListBySubscriptionID response. +func (client *MonitorsClient) listBySubscriptionIDHandleResponse(resp *http.Response) (MonitorsClientListBySubscriptionIDResponse, error) { + result := MonitorsClientListBySubscriptionIDResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.MonitorResourceListResult); err != nil { + return MonitorsClientListBySubscriptionIDResponse{}, err + } + return result, nil +} + +// NewListHostsPager - List the compute resources currently being monitored by the Dynatrace resource. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. The name is case insensitive. +// monitorName - Monitor resource name +// options - MonitorsClientListHostsOptions contains the optional parameters for the MonitorsClient.ListHosts method. +func (client *MonitorsClient) NewListHostsPager(resourceGroupName string, monitorName string, options *MonitorsClientListHostsOptions) *runtime.Pager[MonitorsClientListHostsResponse] { + return runtime.NewPager(runtime.PageProcessor[MonitorsClientListHostsResponse]{ + More: func(page MonitorsClientListHostsResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *MonitorsClientListHostsResponse) (MonitorsClientListHostsResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listHostsCreateRequest(ctx, resourceGroupName, monitorName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return MonitorsClientListHostsResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return MonitorsClientListHostsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return MonitorsClientListHostsResponse{}, runtime.NewResponseError(resp) + } + return client.listHostsHandleResponse(resp) + }, + }) +} + +// listHostsCreateRequest creates the ListHosts request. +func (client *MonitorsClient) listHostsCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsClientListHostsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Dynatrace.Observability/monitors/{monitorName}/listHosts" + 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHostsHandleResponse handles the ListHosts response. +func (client *MonitorsClient) listHostsHandleResponse(resp *http.Response) (MonitorsClientListHostsResponse, error) { + result := MonitorsClientListHostsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.VMHostsListResponse); err != nil { + return MonitorsClientListHostsResponse{}, err + } + return result, nil +} + +// NewListLinkableEnvironmentsPager - Gets all the Dynatrace environments that a user can link a azure resource to +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. The name is case insensitive. +// monitorName - Monitor resource name +// request - The details of the linkable environment request. +// options - MonitorsClientListLinkableEnvironmentsOptions contains the optional parameters for the MonitorsClient.ListLinkableEnvironments +// method. +func (client *MonitorsClient) NewListLinkableEnvironmentsPager(resourceGroupName string, monitorName string, request LinkableEnvironmentRequest, options *MonitorsClientListLinkableEnvironmentsOptions) *runtime.Pager[MonitorsClientListLinkableEnvironmentsResponse] { + return runtime.NewPager(runtime.PageProcessor[MonitorsClientListLinkableEnvironmentsResponse]{ + More: func(page MonitorsClientListLinkableEnvironmentsResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *MonitorsClientListLinkableEnvironmentsResponse) (MonitorsClientListLinkableEnvironmentsResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listLinkableEnvironmentsCreateRequest(ctx, resourceGroupName, monitorName, request, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return MonitorsClientListLinkableEnvironmentsResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return MonitorsClientListLinkableEnvironmentsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return MonitorsClientListLinkableEnvironmentsResponse{}, runtime.NewResponseError(resp) + } + return client.listLinkableEnvironmentsHandleResponse(resp) + }, + }) +} + +// listLinkableEnvironmentsCreateRequest creates the ListLinkableEnvironments request. +func (client *MonitorsClient) listLinkableEnvironmentsCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, request LinkableEnvironmentRequest, options *MonitorsClientListLinkableEnvironmentsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Dynatrace.Observability/monitors/{monitorName}/listLinkableEnvironments" + 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, request) +} + +// listLinkableEnvironmentsHandleResponse handles the ListLinkableEnvironments response. +func (client *MonitorsClient) listLinkableEnvironmentsHandleResponse(resp *http.Response) (MonitorsClientListLinkableEnvironmentsResponse, error) { + result := MonitorsClientListLinkableEnvironmentsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.LinkableEnvironmentListResponse); err != nil { + return MonitorsClientListLinkableEnvironmentsResponse{}, err + } + return result, nil +} + +// NewListMonitoredResourcesPager - List the resources currently being monitored by the Dynatrace monitor resource. +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. The name is case insensitive. +// monitorName - Monitor resource name +// options - MonitorsClientListMonitoredResourcesOptions contains the optional parameters for the MonitorsClient.ListMonitoredResources +// method. +func (client *MonitorsClient) NewListMonitoredResourcesPager(resourceGroupName string, monitorName string, options *MonitorsClientListMonitoredResourcesOptions) *runtime.Pager[MonitorsClientListMonitoredResourcesResponse] { + return runtime.NewPager(runtime.PageProcessor[MonitorsClientListMonitoredResourcesResponse]{ + More: func(page MonitorsClientListMonitoredResourcesResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *MonitorsClientListMonitoredResourcesResponse) (MonitorsClientListMonitoredResourcesResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listMonitoredResourcesCreateRequest(ctx, resourceGroupName, monitorName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return MonitorsClientListMonitoredResourcesResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return MonitorsClientListMonitoredResourcesResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return MonitorsClientListMonitoredResourcesResponse{}, runtime.NewResponseError(resp) + } + return client.listMonitoredResourcesHandleResponse(resp) + }, + }) +} + +// listMonitoredResourcesCreateRequest creates the ListMonitoredResources request. +func (client *MonitorsClient) listMonitoredResourcesCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsClientListMonitoredResourcesOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Dynatrace.Observability/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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listMonitoredResourcesHandleResponse handles the ListMonitoredResources response. +func (client *MonitorsClient) listMonitoredResourcesHandleResponse(resp *http.Response) (MonitorsClientListMonitoredResourcesResponse, error) { + result := MonitorsClientListMonitoredResourcesResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.MonitoredResourceListResponse); err != nil { + return MonitorsClientListMonitoredResourcesResponse{}, err + } + return result, nil +} + +// Update - Update a MonitorResource +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. The name is case insensitive. +// monitorName - Monitor resource name +// resource - The resource properties to be updated. +// options - MonitorsClientUpdateOptions contains the optional parameters for the MonitorsClient.Update method. +func (client *MonitorsClient) Update(ctx context.Context, resourceGroupName string, monitorName string, resource MonitorResourceUpdate, options *MonitorsClientUpdateOptions) (MonitorsClientUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, monitorName, resource, options) + if err != nil { + return MonitorsClientUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return MonitorsClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return MonitorsClientUpdateResponse{}, runtime.NewResponseError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *MonitorsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, resource MonitorResourceUpdate, options *MonitorsClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Dynatrace.Observability/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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, resource) +} + +// updateHandleResponse handles the Update response. +func (client *MonitorsClient) updateHandleResponse(resp *http.Response) (MonitorsClientUpdateResponse, error) { + result := MonitorsClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.MonitorResource); err != nil { + return MonitorsClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/dynatrace/armdynatrace/zz_generated_operations_client.go b/sdk/resourcemanager/dynatrace/armdynatrace/zz_generated_operations_client.go new file mode 100644 index 000000000000..0fffeecdc237 --- /dev/null +++ b/sdk/resourcemanager/dynatrace/armdynatrace/zz_generated_operations_client.go @@ -0,0 +1,103 @@ +//go:build go1.18 +// +build go1.18 + +// 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 armdynatrace + +import ( + "context" + "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/cloud" + "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 { + host string + pl runtime.Pipeline +} + +// NewOperationsClient creates a new instance of OperationsClient with the specified values. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublicCloud.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &OperationsClient{ + host: ep, + pl: pl, + } + return client, nil +} + +// NewListPager - List the operations for Dynatrace.Observability +// If the operation fails it returns an *azcore.ResponseError type. +// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { + return runtime.NewPager(runtime.PageProcessor[OperationsClientListResponse]{ + More: func(page OperationsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *OperationsClientListResponse) (OperationsClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return OperationsClientListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return OperationsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return OperationsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Dynatrace.Observability/operations" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01-preview") + 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) (OperationsClientListResponse, error) { + result := OperationsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationListResult); err != nil { + return OperationsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/dynatrace/armdynatrace/zz_generated_response_types.go b/sdk/resourcemanager/dynatrace/armdynatrace/zz_generated_response_types.go new file mode 100644 index 000000000000..0af2c6b5c144 --- /dev/null +++ b/sdk/resourcemanager/dynatrace/armdynatrace/zz_generated_response_types.go @@ -0,0 +1,119 @@ +//go:build go1.18 +// +build go1.18 + +// 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 armdynatrace + +// MonitorsClientCreateOrUpdateResponse contains the response from method MonitorsClient.CreateOrUpdate. +type MonitorsClientCreateOrUpdateResponse struct { + MonitorResource +} + +// MonitorsClientDeleteResponse contains the response from method MonitorsClient.Delete. +type MonitorsClientDeleteResponse struct { + // placeholder for future response values +} + +// MonitorsClientGetAccountCredentialsResponse contains the response from method MonitorsClient.GetAccountCredentials. +type MonitorsClientGetAccountCredentialsResponse struct { + AccountInfoSecure +} + +// MonitorsClientGetResponse contains the response from method MonitorsClient.Get. +type MonitorsClientGetResponse struct { + MonitorResource +} + +// MonitorsClientGetSSODetailsResponse contains the response from method MonitorsClient.GetSSODetails. +type MonitorsClientGetSSODetailsResponse struct { + SSODetailsResponse +} + +// MonitorsClientGetVMHostPayloadResponse contains the response from method MonitorsClient.GetVMHostPayload. +type MonitorsClientGetVMHostPayloadResponse struct { + VMExtensionPayload +} + +// MonitorsClientListAppServicesResponse contains the response from method MonitorsClient.ListAppServices. +type MonitorsClientListAppServicesResponse struct { + AppServiceListResponse +} + +// MonitorsClientListByResourceGroupResponse contains the response from method MonitorsClient.ListByResourceGroup. +type MonitorsClientListByResourceGroupResponse struct { + MonitorResourceListResult +} + +// MonitorsClientListBySubscriptionIDResponse contains the response from method MonitorsClient.ListBySubscriptionID. +type MonitorsClientListBySubscriptionIDResponse struct { + MonitorResourceListResult +} + +// MonitorsClientListHostsResponse contains the response from method MonitorsClient.ListHosts. +type MonitorsClientListHostsResponse struct { + VMHostsListResponse +} + +// MonitorsClientListLinkableEnvironmentsResponse contains the response from method MonitorsClient.ListLinkableEnvironments. +type MonitorsClientListLinkableEnvironmentsResponse struct { + LinkableEnvironmentListResponse +} + +// MonitorsClientListMonitoredResourcesResponse contains the response from method MonitorsClient.ListMonitoredResources. +type MonitorsClientListMonitoredResourcesResponse struct { + MonitoredResourceListResponse +} + +// MonitorsClientUpdateResponse contains the response from method MonitorsClient.Update. +type MonitorsClientUpdateResponse struct { + MonitorResource +} + +// OperationsClientListResponse contains the response from method OperationsClient.List. +type OperationsClientListResponse struct { + OperationListResult +} + +// SingleSignOnClientCreateOrUpdateResponse contains the response from method SingleSignOnClient.CreateOrUpdate. +type SingleSignOnClientCreateOrUpdateResponse struct { + SingleSignOnResource +} + +// SingleSignOnClientGetResponse contains the response from method SingleSignOnClient.Get. +type SingleSignOnClientGetResponse struct { + SingleSignOnResource +} + +// SingleSignOnClientListResponse contains the response from method SingleSignOnClient.List. +type SingleSignOnClientListResponse struct { + SingleSignOnResourceListResult +} + +// TagRulesClientCreateOrUpdateResponse contains the response from method TagRulesClient.CreateOrUpdate. +type TagRulesClientCreateOrUpdateResponse struct { + TagRule +} + +// TagRulesClientDeleteResponse contains the response from method TagRulesClient.Delete. +type TagRulesClientDeleteResponse struct { + // placeholder for future response values +} + +// TagRulesClientGetResponse contains the response from method TagRulesClient.Get. +type TagRulesClientGetResponse struct { + TagRule +} + +// TagRulesClientListResponse contains the response from method TagRulesClient.List. +type TagRulesClientListResponse struct { + TagRuleListResult +} + +// TagRulesClientUpdateResponse contains the response from method TagRulesClient.Update. +type TagRulesClientUpdateResponse struct { + TagRule +} diff --git a/sdk/resourcemanager/dynatrace/armdynatrace/zz_generated_singlesignon_client.go b/sdk/resourcemanager/dynatrace/armdynatrace/zz_generated_singlesignon_client.go new file mode 100644 index 000000000000..225aed38177e --- /dev/null +++ b/sdk/resourcemanager/dynatrace/armdynatrace/zz_generated_singlesignon_client.go @@ -0,0 +1,252 @@ +//go:build go1.18 +// +build go1.18 + +// 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 armdynatrace + +import ( + "context" + "errors" + "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/cloud" + "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" +) + +// SingleSignOnClient contains the methods for the SingleSignOn group. +// Don't use this type directly, use NewSingleSignOnClient() instead. +type SingleSignOnClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewSingleSignOnClient creates a new instance of SingleSignOnClient with the specified values. +// subscriptionID - The ID of the target subscription. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewSingleSignOnClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SingleSignOnClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublicCloud.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &SingleSignOnClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// BeginCreateOrUpdate - Create a DynatraceSingleSignOnResource +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. The name is case insensitive. +// monitorName - Monitor resource name +// configurationName - Single Sign On Configuration Name +// resource - Resource create parameters. +// options - SingleSignOnClientBeginCreateOrUpdateOptions contains the optional parameters for the SingleSignOnClient.BeginCreateOrUpdate +// method. +func (client *SingleSignOnClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, monitorName string, configurationName string, resource SingleSignOnResource, options *SingleSignOnClientBeginCreateOrUpdateOptions) (*armruntime.Poller[SingleSignOnClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, monitorName, configurationName, resource, options) + if err != nil { + return nil, err + } + return armruntime.NewPoller(resp, client.pl, &armruntime.NewPollerOptions[SingleSignOnClientCreateOrUpdateResponse]{ + FinalStateVia: armruntime.FinalStateViaAzureAsyncOp, + }) + } else { + return armruntime.NewPollerFromResumeToken[SingleSignOnClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// CreateOrUpdate - Create a DynatraceSingleSignOnResource +// If the operation fails it returns an *azcore.ResponseError type. +func (client *SingleSignOnClient) createOrUpdate(ctx context.Context, resourceGroupName string, monitorName string, configurationName string, resource SingleSignOnResource, options *SingleSignOnClientBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, monitorName, configurationName, resource, 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, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *SingleSignOnClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, configurationName string, resource SingleSignOnResource, options *SingleSignOnClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Dynatrace.Observability/monitors/{monitorName}/singleSignOnConfigurations/{configurationName}" + 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 configurationName == "" { + return nil, errors.New("parameter configurationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{configurationName}", url.PathEscape(configurationName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, resource) +} + +// Get - Get a DynatraceSingleSignOnResource +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. The name is case insensitive. +// monitorName - Monitor resource name +// configurationName - Single Sign On Configuration Name +// options - SingleSignOnClientGetOptions contains the optional parameters for the SingleSignOnClient.Get method. +func (client *SingleSignOnClient) Get(ctx context.Context, resourceGroupName string, monitorName string, configurationName string, options *SingleSignOnClientGetOptions) (SingleSignOnClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, monitorName, configurationName, options) + if err != nil { + return SingleSignOnClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return SingleSignOnClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return SingleSignOnClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *SingleSignOnClient) getCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, configurationName string, options *SingleSignOnClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Dynatrace.Observability/monitors/{monitorName}/singleSignOnConfigurations/{configurationName}" + 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 configurationName == "" { + return nil, errors.New("parameter configurationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{configurationName}", url.PathEscape(configurationName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *SingleSignOnClient) getHandleResponse(resp *http.Response) (SingleSignOnClientGetResponse, error) { + result := SingleSignOnClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SingleSignOnResource); err != nil { + return SingleSignOnClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - List all DynatraceSingleSignOnResource by monitorName +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. The name is case insensitive. +// monitorName - Monitor resource name +// options - SingleSignOnClientListOptions contains the optional parameters for the SingleSignOnClient.List method. +func (client *SingleSignOnClient) NewListPager(resourceGroupName string, monitorName string, options *SingleSignOnClientListOptions) *runtime.Pager[SingleSignOnClientListResponse] { + return runtime.NewPager(runtime.PageProcessor[SingleSignOnClientListResponse]{ + More: func(page SingleSignOnClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *SingleSignOnClientListResponse) (SingleSignOnClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, resourceGroupName, monitorName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return SingleSignOnClientListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return SingleSignOnClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return SingleSignOnClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *SingleSignOnClient) listCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, options *SingleSignOnClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Dynatrace.Observability/monitors/{monitorName}/singleSignOnConfigurations" + 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *SingleSignOnClient) listHandleResponse(resp *http.Response) (SingleSignOnClientListResponse, error) { + result := SingleSignOnClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SingleSignOnResourceListResult); err != nil { + return SingleSignOnClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/dynatrace/armdynatrace/zz_generated_tagrules_client.go b/sdk/resourcemanager/dynatrace/armdynatrace/zz_generated_tagrules_client.go new file mode 100644 index 000000000000..9f4b028a3b3c --- /dev/null +++ b/sdk/resourcemanager/dynatrace/armdynatrace/zz_generated_tagrules_client.go @@ -0,0 +1,380 @@ +//go:build go1.18 +// +build go1.18 + +// 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 armdynatrace + +import ( + "context" + "errors" + "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/cloud" + "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 { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewTagRulesClient creates a new instance of TagRulesClient with the specified values. +// subscriptionID - The ID of the target subscription. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewTagRulesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*TagRulesClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublicCloud.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &TagRulesClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// BeginCreateOrUpdate - Create a TagRule +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. The name is case insensitive. +// monitorName - Monitor resource name +// ruleSetName - Monitor resource name +// resource - Resource create parameters. +// options - TagRulesClientBeginCreateOrUpdateOptions contains the optional parameters for the TagRulesClient.BeginCreateOrUpdate +// method. +func (client *TagRulesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, resource TagRule, options *TagRulesClientBeginCreateOrUpdateOptions) (*armruntime.Poller[TagRulesClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, monitorName, ruleSetName, resource, options) + if err != nil { + return nil, err + } + return armruntime.NewPoller(resp, client.pl, &armruntime.NewPollerOptions[TagRulesClientCreateOrUpdateResponse]{ + FinalStateVia: armruntime.FinalStateViaAzureAsyncOp, + }) + } else { + return armruntime.NewPollerFromResumeToken[TagRulesClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// CreateOrUpdate - Create a TagRule +// If the operation fails it returns an *azcore.ResponseError type. +func (client *TagRulesClient) createOrUpdate(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, resource TagRule, options *TagRulesClientBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, monitorName, ruleSetName, resource, 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, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *TagRulesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, resource TagRule, options *TagRulesClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Dynatrace.Observability/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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, resource) +} + +// BeginDelete - Delete a TagRule +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. The name is case insensitive. +// monitorName - Monitor resource name +// ruleSetName - Monitor resource name +// options - TagRulesClientBeginDeleteOptions contains the optional parameters for the TagRulesClient.BeginDelete method. +func (client *TagRulesClient) BeginDelete(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, options *TagRulesClientBeginDeleteOptions) (*armruntime.Poller[TagRulesClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, monitorName, ruleSetName, options) + if err != nil { + return nil, err + } + return armruntime.NewPoller(resp, client.pl, &armruntime.NewPollerOptions[TagRulesClientDeleteResponse]{ + FinalStateVia: armruntime.FinalStateViaAzureAsyncOp, + }) + } else { + return armruntime.NewPollerFromResumeToken[TagRulesClientDeleteResponse](options.ResumeToken, client.pl, nil) + } +} + +// Delete - Delete a TagRule +// If the operation fails it returns an *azcore.ResponseError type. +func (client *TagRulesClient) deleteOperation(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, options *TagRulesClientBeginDeleteOptions) (*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, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *TagRulesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, options *TagRulesClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Dynatrace.Observability/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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// Get - Get a TagRule +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. The name is case insensitive. +// monitorName - Monitor resource name +// ruleSetName - Monitor resource name +// options - TagRulesClientGetOptions contains the optional parameters for the TagRulesClient.Get method. +func (client *TagRulesClient) Get(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, options *TagRulesClientGetOptions) (TagRulesClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, monitorName, ruleSetName, options) + if err != nil { + return TagRulesClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return TagRulesClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return TagRulesClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *TagRulesClient) getCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, options *TagRulesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Dynatrace.Observability/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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01-preview") + 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) (TagRulesClientGetResponse, error) { + result := TagRulesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TagRule); err != nil { + return TagRulesClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - List all TagRule by monitorName +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. The name is case insensitive. +// monitorName - Monitor resource name +// options - TagRulesClientListOptions contains the optional parameters for the TagRulesClient.List method. +func (client *TagRulesClient) NewListPager(resourceGroupName string, monitorName string, options *TagRulesClientListOptions) *runtime.Pager[TagRulesClientListResponse] { + return runtime.NewPager(runtime.PageProcessor[TagRulesClientListResponse]{ + More: func(page TagRulesClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *TagRulesClientListResponse) (TagRulesClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, resourceGroupName, monitorName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return TagRulesClientListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return TagRulesClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return TagRulesClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *TagRulesClient) listCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, options *TagRulesClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Dynatrace.Observability/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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01-preview") + 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) (TagRulesClientListResponse, error) { + result := TagRulesClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TagRuleListResult); err != nil { + return TagRulesClientListResponse{}, err + } + return result, nil +} + +// Update - Update a TagRule +// If the operation fails it returns an *azcore.ResponseError type. +// resourceGroupName - The name of the resource group. The name is case insensitive. +// monitorName - Monitor resource name +// ruleSetName - Monitor resource name +// resource - The resource properties to be updated. +// options - TagRulesClientUpdateOptions contains the optional parameters for the TagRulesClient.Update method. +func (client *TagRulesClient) Update(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, resource TagRuleUpdate, options *TagRulesClientUpdateOptions) (TagRulesClientUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, monitorName, ruleSetName, resource, options) + if err != nil { + return TagRulesClientUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return TagRulesClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return TagRulesClientUpdateResponse{}, runtime.NewResponseError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *TagRulesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, resource TagRuleUpdate, options *TagRulesClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Dynatrace.Observability/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.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, resource) +} + +// updateHandleResponse handles the Update response. +func (client *TagRulesClient) updateHandleResponse(resp *http.Response) (TagRulesClientUpdateResponse, error) { + result := TagRulesClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TagRule); err != nil { + return TagRulesClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/dynatrace/armdynatrace/zz_generated_time_rfc3339.go b/sdk/resourcemanager/dynatrace/armdynatrace/zz_generated_time_rfc3339.go new file mode 100644 index 000000000000..5fa5d6ac1904 --- /dev/null +++ b/sdk/resourcemanager/dynatrace/armdynatrace/zz_generated_time_rfc3339.go @@ -0,0 +1,85 @@ +//go:build go1.18 +// +build go1.18 + +// 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 armdynatrace + +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 +}