diff --git a/sdk/resourcemanager/newrelic/armnewrelic/CHANGELOG.md b/sdk/resourcemanager/newrelic/armnewrelic/CHANGELOG.md new file mode 100644 index 000000000000..36e4066d69d8 --- /dev/null +++ b/sdk/resourcemanager/newrelic/armnewrelic/CHANGELOG.md @@ -0,0 +1,7 @@ +# Release History + +## 0.1.0 (2023-02-12) + +The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/newrelic/armnewrelic` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html). + +To learn more, please refer to our documentation [Quick Start](https://aka.ms/azsdk/go/mgmt). \ No newline at end of file diff --git a/sdk/resourcemanager/newrelic/armnewrelic/LICENSE.txt b/sdk/resourcemanager/newrelic/armnewrelic/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/newrelic/armnewrelic/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/newrelic/armnewrelic/README.md b/sdk/resourcemanager/newrelic/armnewrelic/README.md new file mode 100644 index 000000000000..70e4e1e7eb18 --- /dev/null +++ b/sdk/resourcemanager/newrelic/armnewrelic/README.md @@ -0,0 +1,77 @@ +# Azure Newrelic Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/newrelic/armnewrelic)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/newrelic/armnewrelic) + +The `armnewrelic` module provides operations for working with Azure Newrelic. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/newrelic/armnewrelic) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.18 or above (You could download and install the latest version of Go from [here](https://go.dev/doc/install). It will replace the existing Go on your machine. If you want to install multiple Go versions on the same machine, you could refer this [doc](https://go.dev/doc/manage-install).) + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Newrelic module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/newrelic/armnewrelic +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Newrelic. 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 Newrelic 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 := armnewrelic.NewAccountsClient(, 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 := armnewrelic.NewAccountsClient(, 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 `Newrelic` 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/newrelic/armnewrelic/accounts_client.go b/sdk/resourcemanager/newrelic/armnewrelic/accounts_client.go new file mode 100644 index 000000000000..40bf6ca7f410 --- /dev/null +++ b/sdk/resourcemanager/newrelic/armnewrelic/accounts_client.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. +// DO NOT EDIT. + +package armnewrelic + +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" +) + +// AccountsClient contains the methods for the Accounts group. +// Don't use this type directly, use NewAccountsClient() instead. +type AccountsClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewAccountsClient creates a new instance of AccountsClient 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 NewAccountsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AccountsClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.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 := &AccountsClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// NewListPager - List all the existing accounts +// +// Generated from API version 2022-07-01-preview +// - userEmail - User Email. +// - location - Location for NewRelic. +// - options - AccountsClientListOptions contains the optional parameters for the AccountsClient.NewListPager method. +func (client *AccountsClient) NewListPager(userEmail string, location string, options *AccountsClientListOptions) *runtime.Pager[AccountsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[AccountsClientListResponse]{ + More: func(page AccountsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *AccountsClientListResponse) (AccountsClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, userEmail, location, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return AccountsClientListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AccountsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AccountsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *AccountsClient) listCreateRequest(ctx context.Context, userEmail string, location string, options *AccountsClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/NewRelic.Observability/accounts" + 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", "2022-07-01-preview") + reqQP.Set("userEmail", userEmail) + reqQP.Set("location", location) + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *AccountsClient) listHandleResponse(resp *http.Response) (AccountsClientListResponse, error) { + result := AccountsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AccountsListResponse); err != nil { + return AccountsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/newrelic/armnewrelic/autorest.md b/sdk/resourcemanager/newrelic/armnewrelic/autorest.md new file mode 100644 index 000000000000..226b3fcb9e34 --- /dev/null +++ b/sdk/resourcemanager/newrelic/armnewrelic/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/newrelic/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/newrelic/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/newrelic/armnewrelic/build.go b/sdk/resourcemanager/newrelic/armnewrelic/build.go new file mode 100644 index 000000000000..085a9a5420d4 --- /dev/null +++ b/sdk/resourcemanager/newrelic/armnewrelic/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 ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate -alwaysSetBodyParamRequired -removeUnreferencedTypes resourcemanager/newrelic/armnewrelic + +package armnewrelic diff --git a/sdk/resourcemanager/newrelic/armnewrelic/ci.yml b/sdk/resourcemanager/newrelic/armnewrelic/ci.yml new file mode 100644 index 000000000000..4ade8f1cf09e --- /dev/null +++ b/sdk/resourcemanager/newrelic/armnewrelic/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/newrelic/armnewrelic/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/newrelic/armnewrelic/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + IncludeRelease: true + ServiceDirectory: 'resourcemanager/newrelic/armnewrelic' diff --git a/sdk/resourcemanager/newrelic/armnewrelic/constants.go b/sdk/resourcemanager/newrelic/armnewrelic/constants.go new file mode 100644 index 000000000000..3da8cf1262c0 --- /dev/null +++ b/sdk/resourcemanager/newrelic/armnewrelic/constants.go @@ -0,0 +1,404 @@ +//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. +// DO NOT EDIT. + +package armnewrelic + +const ( + moduleName = "armnewrelic" + moduleVersion = "v0.1.0" +) + +// AccountCreationSource - Source of Account creation +type AccountCreationSource string + +const ( + // AccountCreationSourceLIFTR - Account is created from LIFTR + AccountCreationSourceLIFTR AccountCreationSource = "LIFTR" + // AccountCreationSourceNEWRELIC - Account is created from NEWRELIC + AccountCreationSourceNEWRELIC AccountCreationSource = "NEWRELIC" +) + +// PossibleAccountCreationSourceValues returns the possible values for the AccountCreationSource const type. +func PossibleAccountCreationSourceValues() []AccountCreationSource { + return []AccountCreationSource{ + AccountCreationSourceLIFTR, + AccountCreationSourceNEWRELIC, + } +} + +// 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, + } +} + +// BillingCycle - Different usage type like YEARLY/MONTHLY +type BillingCycle string + +const ( + // BillingCycleMONTHLY - Billing cycle is MONTHLY + BillingCycleMONTHLY BillingCycle = "MONTHLY" + // BillingCycleWEEKLY - Billing cycle is WEEKLY + BillingCycleWEEKLY BillingCycle = "WEEKLY" + // BillingCycleYEARLY - Billing cycle is YEARLY + BillingCycleYEARLY BillingCycle = "YEARLY" +) + +// PossibleBillingCycleValues returns the possible values for the BillingCycle const type. +func PossibleBillingCycleValues() []BillingCycle { + return []BillingCycle{ + BillingCycleMONTHLY, + BillingCycleWEEKLY, + BillingCycleYEARLY, + } +} + +// BillingSource - Billing source +type BillingSource string + +const ( + // BillingSourceAZURE - Billing source is Azure + BillingSourceAZURE BillingSource = "AZURE" + BillingSourceNEWRELIC BillingSource = "NEWRELIC" +) + +// PossibleBillingSourceValues returns the possible values for the BillingSource const type. +func PossibleBillingSourceValues() []BillingSource { + return []BillingSource{ + BillingSourceAZURE, + BillingSourceNEWRELIC, + } +} + +// 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, + } +} + +// ManagedServiceIdentityType - Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). +type ManagedServiceIdentityType string + +const ( + ManagedServiceIdentityTypeNone ManagedServiceIdentityType = "None" + ManagedServiceIdentityTypeSystemAssigned ManagedServiceIdentityType = "SystemAssigned" + ManagedServiceIdentityTypeSystemAssignedUserAssigned ManagedServiceIdentityType = "SystemAssigned, UserAssigned" + ManagedServiceIdentityTypeUserAssigned ManagedServiceIdentityType = "UserAssigned" +) + +// PossibleManagedServiceIdentityTypeValues returns the possible values for the ManagedServiceIdentityType const type. +func PossibleManagedServiceIdentityTypeValues() []ManagedServiceIdentityType { + return []ManagedServiceIdentityType{ + ManagedServiceIdentityTypeNone, + ManagedServiceIdentityTypeSystemAssigned, + ManagedServiceIdentityTypeSystemAssignedUserAssigned, + ManagedServiceIdentityTypeUserAssigned, + } +} + +// 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 - monitoring is enabled + MarketplaceSubscriptionStatusActive MarketplaceSubscriptionStatus = "Active" + // MarketplaceSubscriptionStatusSuspended - monitoring is disabled + 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 - monitoring is disabled + MonitoringStatusDisabled MonitoringStatus = "Disabled" + // MonitoringStatusEnabled - monitoring is enabled + MonitoringStatusEnabled MonitoringStatus = "Enabled" +) + +// PossibleMonitoringStatusValues returns the possible values for the MonitoringStatus const type. +func PossibleMonitoringStatusValues() []MonitoringStatus { + return []MonitoringStatus{ + MonitoringStatusDisabled, + MonitoringStatusEnabled, + } +} + +// OrgCreationSource - Source of Org creation +type OrgCreationSource string + +const ( + // OrgCreationSourceLIFTR - Org is created from LIFTR + OrgCreationSourceLIFTR OrgCreationSource = "LIFTR" + // OrgCreationSourceNEWRELIC - Org is created from NEWRELIC + OrgCreationSourceNEWRELIC OrgCreationSource = "NEWRELIC" +) + +// PossibleOrgCreationSourceValues returns the possible values for the OrgCreationSource const type. +func PossibleOrgCreationSourceValues() []OrgCreationSource { + return []OrgCreationSource{ + OrgCreationSourceLIFTR, + OrgCreationSourceNEWRELIC, + } +} + +// 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 Monitor resource +type ProvisioningState string + +const ( + // ProvisioningStateAccepted - Monitor resource creation request accepted + ProvisioningStateAccepted ProvisioningState = "Accepted" + // ProvisioningStateCanceled - Monitor resource creation canceled + ProvisioningStateCanceled ProvisioningState = "Canceled" + // ProvisioningStateCreating - Monitor resource creation started + ProvisioningStateCreating ProvisioningState = "Creating" + // ProvisioningStateDeleted - Monitor resource is deleted + ProvisioningStateDeleted ProvisioningState = "Deleted" + // ProvisioningStateDeleting - Monitor resource deletion started + ProvisioningStateDeleting ProvisioningState = "Deleting" + // ProvisioningStateFailed - Monitor resource creation failed + ProvisioningStateFailed ProvisioningState = "Failed" + // ProvisioningStateNotSpecified - Monitor resource state is unknown + ProvisioningStateNotSpecified ProvisioningState = "NotSpecified" + // ProvisioningStateSucceeded - Monitor resource creation successful + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + // ProvisioningStateUpdating - Monitor resource is being updated + 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, + } +} + +// 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, + } +} + +// SendMetricsStatus - Indicates whether metrics are being sent. +type SendMetricsStatus string + +const ( + SendMetricsStatusDisabled SendMetricsStatus = "Disabled" + SendMetricsStatusEnabled SendMetricsStatus = "Enabled" +) + +// PossibleSendMetricsStatusValues returns the possible values for the SendMetricsStatus const type. +func PossibleSendMetricsStatusValues() []SendMetricsStatus { + return []SendMetricsStatus{ + SendMetricsStatusDisabled, + SendMetricsStatusEnabled, + } +} + +// 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, + } +} + +// UsageType - Different usage type like PAYG/COMMITTED +type UsageType string + +const ( + // UsageTypeCOMMITTED - Usage type is COMMITTED + UsageTypeCOMMITTED UsageType = "COMMITTED" + // UsageTypePAYG - Usage type is PAYG + UsageTypePAYG UsageType = "PAYG" +) + +// PossibleUsageTypeValues returns the possible values for the UsageType const type. +func PossibleUsageTypeValues() []UsageType { + return []UsageType{ + UsageTypeCOMMITTED, + UsageTypePAYG, + } +} diff --git a/sdk/resourcemanager/newrelic/armnewrelic/go.mod b/sdk/resourcemanager/newrelic/armnewrelic/go.mod new file mode 100644 index 000000000000..0bbbc4a39f20 --- /dev/null +++ b/sdk/resourcemanager/newrelic/armnewrelic/go.mod @@ -0,0 +1,13 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/newrelic/armnewrelic + +go 1.18 + +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect + golang.org/x/text v0.3.7 // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect +) diff --git a/sdk/resourcemanager/newrelic/armnewrelic/go.sum b/sdk/resourcemanager/newrelic/armnewrelic/go.sum new file mode 100644 index 000000000000..3afb578030a5 --- /dev/null +++ b/sdk/resourcemanager/newrelic/armnewrelic/go.sum @@ -0,0 +1,15 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= +golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/newrelic/armnewrelic/models.go b/sdk/resourcemanager/newrelic/armnewrelic/models.go new file mode 100644 index 000000000000..772551468888 --- /dev/null +++ b/sdk/resourcemanager/newrelic/armnewrelic/models.go @@ -0,0 +1,761 @@ +//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. +// DO NOT EDIT. + +package armnewrelic + +import "time" + +// AccountInfo - Account Info of the NewRelic account +type AccountInfo struct { + // Account id + AccountID *string `json:"accountId,omitempty"` + + // ingestion key of account + IngestionKey *string `json:"ingestionKey,omitempty"` + + // NewRelic account region + Region *string `json:"region,omitempty"` +} + +// AccountProperties - List of all the New relic accounts for the given user +type AccountProperties struct { + // account id + AccountID *string `json:"accountId,omitempty"` + + // account name + AccountName *string `json:"accountName,omitempty"` + + // organization id + OrganizationID *string `json:"organizationId,omitempty"` + + // region + Region *string `json:"region,omitempty"` +} + +// AccountPropertiesForNewRelic - Properties of the NewRelic account +type AccountPropertiesForNewRelic struct { + // NewRelic Account Information + AccountInfo *AccountInfo `json:"accountInfo,omitempty"` + + // NewRelic Organization Information + OrganizationInfo *OrganizationInfo `json:"organizationInfo,omitempty"` + + // date when plan was applied + SingleSignOnProperties *SingleSignOnProperties `json:"singleSignOnProperties,omitempty"` + + // User id + UserID *string `json:"userId,omitempty"` +} + +// AccountResource - The details of a account resource. +type AccountResource struct { + // The resource-specific properties for this resource. + Properties *AccountProperties `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; Azure Resource Manager metadata containing createdBy and modifiedBy information. + 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"` +} + +// AccountsClientListOptions contains the optional parameters for the AccountsClient.NewListPager method. +type AccountsClientListOptions struct { + // placeholder for future optional parameters +} + +// AccountsListResponse - Response of get all accounts Operation. +type AccountsListResponse struct { + // REQUIRED; The AccountResource items on this page + Value []*AccountResource `json:"value,omitempty"` + + // The link to the next page of items + NextLink *string `json:"nextLink,omitempty"` +} + +// AppServiceInfo - Details of VM Resource having NewRelic OneAgent installed +type AppServiceInfo struct { + // Status of the NewRelic agent installed on the App service. + AgentStatus *string `json:"agentStatus,omitempty"` + + // Version of the NewRelic agent installed on the App service. + AgentVersion *string `json:"agentVersion,omitempty"` + + // Azure App service resource ID + AzureResourceID *string `json:"azureResourceId,omitempty"` +} + +// AppServicesGetRequest - Request of a app services get Operation. +type AppServicesGetRequest struct { + // REQUIRED; User Email + UserEmail *string `json:"userEmail,omitempty"` + + // Azure resource IDs + AzureResourceIDs []*string `json:"azureResourceIds,omitempty"` +} + +// AppServicesListResponse - Response of a list app services Operation. +type AppServicesListResponse struct { + // REQUIRED; The AppServiceInfo items on this page + Value []*AppServiceInfo `json:"value,omitempty"` + + // The link to the next page of items + NextLink *string `json:"nextLink,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"` +} + +// HostsGetRequest - Request of a Hosts get Operation. +type HostsGetRequest struct { + // REQUIRED; User Email + UserEmail *string `json:"userEmail,omitempty"` + + // VM resource IDs + VMIDs []*string `json:"vmIds,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"` +} + +// ManagedServiceIdentity - Managed service identity (system assigned and/or user assigned identities) +type ManagedServiceIdentity struct { + // REQUIRED; Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). + Type *ManagedServiceIdentityType `json:"type,omitempty"` + + // The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM + // resource ids in the form: + // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. + // The dictionary values can be empty objects ({}) in + // requests. + UserAssignedIdentities map[string]*UserAssignedIdentity `json:"userAssignedIdentities,omitempty"` + + // READ-ONLY; The service principal ID of the system assigned identity. This property will only be provided for a system assigned + // identity. + PrincipalID *string `json:"principalId,omitempty" azure:"ro"` + + // READ-ONLY; The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity. + TenantID *string `json:"tenantId,omitempty" azure:"ro"` +} + +// MetricRules - Set of rules for sending metrics for the Monitor resource. +type MetricRules struct { + // List of filtering tags to be used for capturing metrics. + FilteringTags []*FilteringTag `json:"filteringTags,omitempty"` + + // Flag specifying if metrics should be sent for the Monitor resource. + SendMetrics *SendMetricsStatus `json:"sendMetrics,omitempty"` + + // User Email + UserEmail *string `json:"userEmail,omitempty"` +} + +// MetricsRequest - Request of get metrics Operation. +type MetricsRequest struct { + // REQUIRED; User Email + UserEmail *string `json:"userEmail,omitempty"` +} + +// MetricsStatusRequest - Request of get metrics status Operation. +type MetricsStatusRequest struct { + // REQUIRED; User Email + UserEmail *string `json:"userEmail,omitempty"` + + // Azure resource IDs + AzureResourceIDs []*string `json:"azureResourceIds,omitempty"` +} + +// MetricsStatusResponse - Response of get metrics status Operation. +type MetricsStatusResponse struct { + // Azure resource IDs + AzureResourceIDs []*string `json:"azureResourceIds,omitempty"` +} + +// MonitorProperties - Properties specific to the NewRelic Monitor resource +type MonitorProperties struct { + // Source of account creation + AccountCreationSource *AccountCreationSource `json:"accountCreationSource,omitempty"` + + // MarketplaceSubscriptionStatus of the resource + NewRelicAccountProperties *AccountPropertiesForNewRelic `json:"newRelicAccountProperties,omitempty"` + + // Source of org creation + OrgCreationSource *OrgCreationSource `json:"orgCreationSource,omitempty"` + + // Plan details + 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; Liftr resource preference. The priority of the resource. + LiftrResourcePreference *int32 `json:"liftrResourcePreference,omitempty" azure:"ro"` + + // READ-ONLY; Marketplace Subscription Id + MarketplaceSubscriptionID *string `json:"marketplaceSubscriptionId,omitempty" azure:"ro"` + + // READ-ONLY; NewRelic Organization properties of the resource + MarketplaceSubscriptionStatus *MarketplaceSubscriptionStatus `json:"marketplaceSubscriptionStatus,omitempty" azure:"ro"` + + // READ-ONLY; MonitoringStatus of the resource + MonitoringStatus *MonitoringStatus `json:"monitoringStatus,omitempty" azure:"ro"` + + // READ-ONLY; Provisioning State of the resource + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// MonitorResource - A Monitor Resource by NewRelic +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 *ManagedServiceIdentity `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; Azure Resource Manager metadata containing createdBy and modifiedBy information. + 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 NewRelicMonitorResource list operation. +type MonitorResourceListResult struct { + // REQUIRED; The NewRelicMonitorResource items on this page + Value []*MonitorResource `json:"value,omitempty"` + + // The link to the next page of items + NextLink *string `json:"nextLink,omitempty"` +} + +// MonitorResourceUpdate - The type used for update operations of the NewRelicMonitorResource. +type MonitorResourceUpdate struct { + // The managed service identities assigned to this resource. + Identity *ManagedServiceIdentity `json:"identity,omitempty"` + + // The updatable properties of the NewRelicMonitorResource. + Properties *MonitorResourceUpdateProperties `json:"properties,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// MonitorResourceUpdateProperties - The updatable properties of the NewRelicMonitorResource. +type MonitorResourceUpdateProperties struct { + // Source of account creation + AccountCreationSource *AccountCreationSource `json:"accountCreationSource,omitempty"` + + // MarketplaceSubscriptionStatus of the resource + NewRelicAccountProperties *AccountPropertiesForNewRelic `json:"newRelicAccountProperties,omitempty"` + + // Source of org creation + OrgCreationSource *OrgCreationSource `json:"orgCreationSource,omitempty"` + + // Plan details + PlanData *PlanData `json:"planData,omitempty"` + + // User Info + UserInfo *UserInfo `json:"userInfo,omitempty"` +} + +// MonitoredResource - Details of resource being monitored by NewRelic 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 NewRelic. + SendingLogs *SendingLogsStatus `json:"sendingLogs,omitempty"` + + // Flag indicating if resource is sending metrics to NewRelic. + SendingMetrics *SendingMetricsStatus `json:"sendingMetrics,omitempty"` +} + +// MonitoredResourceListResponse - List of all the resources being monitored by NewRelic monitor resource +type MonitoredResourceListResponse struct { + // REQUIRED; The MonitoredResource items on this page + Value []*MonitoredResource `json:"value,omitempty"` + + // The link to the next page of items + NextLink *string `json:"nextLink,omitempty"` +} + +// MonitoringTagRulesProperties - The resource-specific properties for this resource. +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 +} + +// MonitorsClientGetMetricRulesOptions contains the optional parameters for the MonitorsClient.GetMetricRules method. +type MonitorsClientGetMetricRulesOptions struct { + // placeholder for future optional parameters +} + +// MonitorsClientGetMetricStatusOptions contains the optional parameters for the MonitorsClient.GetMetricStatus method. +type MonitorsClientGetMetricStatusOptions struct { + // placeholder for future optional parameters +} + +// MonitorsClientGetOptions contains the optional parameters for the MonitorsClient.Get method. +type MonitorsClientGetOptions struct { + // placeholder for future optional parameters +} + +// MonitorsClientListAppServicesOptions contains the optional parameters for the MonitorsClient.NewListAppServicesPager method. +type MonitorsClientListAppServicesOptions struct { + // placeholder for future optional parameters +} + +// MonitorsClientListByResourceGroupOptions contains the optional parameters for the MonitorsClient.NewListByResourceGroupPager +// method. +type MonitorsClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// MonitorsClientListBySubscriptionOptions contains the optional parameters for the MonitorsClient.NewListBySubscriptionPager +// method. +type MonitorsClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// MonitorsClientListHostsOptions contains the optional parameters for the MonitorsClient.NewListHostsPager method. +type MonitorsClientListHostsOptions struct { + // placeholder for future optional parameters +} + +// MonitorsClientListMonitoredResourcesOptions contains the optional parameters for the MonitorsClient.NewListMonitoredResourcesPager +// method. +type MonitorsClientListMonitoredResourcesOptions struct { + // placeholder for future optional parameters +} + +// MonitorsClientSwitchBillingOptions contains the optional parameters for the MonitorsClient.SwitchBilling method. +type MonitorsClientSwitchBillingOptions struct { + // placeholder for future optional parameters +} + +// MonitorsClientUpdateOptions contains the optional parameters for the MonitorsClient.Update method. +type MonitorsClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// MonitorsClientVMHostPayloadOptions contains the optional parameters for the MonitorsClient.VMHostPayload method. +type MonitorsClientVMHostPayloadOptions 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.NewListPager method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} + +// OrganizationInfo - Organization Info of the NewRelic account +type OrganizationInfo struct { + // Organization id + OrganizationID *string `json:"organizationId,omitempty"` +} + +// OrganizationProperties - Details of Organizations +type OrganizationProperties struct { + // Billing source + BillingSource *BillingSource `json:"billingSource,omitempty"` + + // organization id + OrganizationID *string `json:"organizationId,omitempty"` + + // organization name + OrganizationName *string `json:"organizationName,omitempty"` +} + +// OrganizationResource - The details of a Organization resource. +type OrganizationResource struct { + // The resource-specific properties for this resource. + Properties *OrganizationProperties `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; Azure Resource Manager metadata containing createdBy and modifiedBy information. + 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"` +} + +// OrganizationsClientListOptions contains the optional parameters for the OrganizationsClient.NewListPager method. +type OrganizationsClientListOptions struct { + // placeholder for future optional parameters +} + +// OrganizationsListResponse - Response of get all organizations Operation. +type OrganizationsListResponse struct { + // REQUIRED; The OrganizationResource items on this page + Value []*OrganizationResource `json:"value,omitempty"` + + // The link to the next page of items + NextLink *string `json:"nextLink,omitempty"` +} + +// PlanData - Plan data of NewRelic Monitor resource +type PlanData struct { + // Different billing cycles like MONTHLY/WEEKLY. this could be enum + BillingCycle *BillingCycle `json:"billingCycle,omitempty"` + + // date when plan was applied + EffectiveDate *time.Time `json:"effectiveDate,omitempty"` + + // plan id as published by NewRelic + PlanDetails *string `json:"planDetails,omitempty"` + + // Different usage type like PAYG/COMMITTED. this could be enum + UsageType *UsageType `json:"usageType,omitempty"` +} + +// PlanDataListResponse - Response of get all plan data Operation. +type PlanDataListResponse struct { + // REQUIRED; The PlanDataResource items on this page + Value []*PlanDataResource `json:"value,omitempty"` + + // The link to the next page of items + NextLink *string `json:"nextLink,omitempty"` +} + +// PlanDataProperties - Plan details +type PlanDataProperties struct { + // Source of account creation + AccountCreationSource *AccountCreationSource `json:"accountCreationSource,omitempty"` + + // Source of org creation + OrgCreationSource *OrgCreationSource `json:"orgCreationSource,omitempty"` + + // Plan details + PlanData *PlanData `json:"planData,omitempty"` +} + +// PlanDataResource - The details of a PlanData resource. +type PlanDataResource struct { + // The resource-specific properties for this resource. + Properties *PlanDataProperties `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; Azure Resource Manager metadata containing createdBy and modifiedBy information. + 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"` +} + +// PlansClientListOptions contains the optional parameters for the PlansClient.NewListPager method. +type PlansClientListOptions struct { + // Account Id. + AccountID *string + // Organization Id. + OrganizationID *string +} + +// SingleSignOnProperties - Single sign on Info of the NewRelic account +type SingleSignOnProperties struct { + // The Id of the Enterprise App used for Single sign-on. + EnterpriseAppID *string `json:"enterpriseAppId,omitempty"` + + // Provisioning state + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + + // Single sign-on state + SingleSignOnState *SingleSignOnStates `json:"singleSignOnState,omitempty"` + + // The login URL specific to this NewRelic Organization + SingleSignOnURL *string `json:"singleSignOnUrl,omitempty"` +} + +// SwitchBillingRequest - Request of a switch billing Operation. +type SwitchBillingRequest struct { + // REQUIRED; User Email + UserEmail *string `json:"userEmail,omitempty"` + + // Azure resource Id + AzureResourceID *string `json:"azureResourceId,omitempty"` + + // Organization id + OrganizationID *string `json:"organizationId,omitempty"` + + // Plan details + PlanData *PlanData `json:"planData,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 - A tag rule belonging to NewRelic account +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; Azure Resource Manager metadata containing createdBy and modifiedBy information. + 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 TagRule items on this page + Value []*TagRule `json:"value,omitempty"` + + // The link to the next page of items + NextLink *string `json:"nextLink,omitempty"` +} + +// TagRuleUpdate - The type used for update operations of the TagRule. +type TagRuleUpdate struct { + // The updatable properties of the TagRule. + Properties *TagRuleUpdateProperties `json:"properties,omitempty"` +} + +// TagRuleUpdateProperties - The updatable properties of the TagRule. +type TagRuleUpdateProperties 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 +} + +// TagRulesClientListByNewRelicMonitorResourceOptions contains the optional parameters for the TagRulesClient.NewListByNewRelicMonitorResourcePager +// method. +type TagRulesClientListByNewRelicMonitorResourceOptions struct { + // placeholder for future optional parameters +} + +// TagRulesClientUpdateOptions contains the optional parameters for the TagRulesClient.Update method. +type TagRulesClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// UserAssignedIdentity - User assigned identity properties +type UserAssignedIdentity struct { + // READ-ONLY; The client ID of the assigned identity. + ClientID *string `json:"clientId,omitempty" azure:"ro"` + + // READ-ONLY; The principal ID of the assigned identity. + PrincipalID *string `json:"principalId,omitempty" azure:"ro"` +} + +// UserInfo - User Info of NewRelic Monitor resource +type UserInfo struct { + // country if user + Country *string `json:"country,omitempty"` + + // User Email + EmailAddress *string `json:"emailAddress,omitempty"` + + // First name + FirstName *string `json:"firstName,omitempty"` + + // Last name + LastName *string `json:"lastName,omitempty"` + + // Contact phone number + PhoneNumber *string `json:"phoneNumber,omitempty"` +} + +// VMExtensionPayload - Response of payload to be passed while installing VM agent. +type VMExtensionPayload struct { + // Ingestion key of the account + IngestionKey *string `json:"ingestionKey,omitempty"` +} + +// VMHostsListResponse - Response of a list VM Host Operation. +type VMHostsListResponse struct { + // REQUIRED; The VMInfo items on this page + Value []*VMInfo `json:"value,omitempty"` + + // The link to the next page of items + NextLink *string `json:"nextLink,omitempty"` +} + +// VMInfo - Details of VM Resource having NewRelic OneAgent installed +type VMInfo struct { + // Status of the NewRelic agent installed on the VM. + AgentStatus *string `json:"agentStatus,omitempty"` + + // Version of the NewRelic agent installed on the VM. + AgentVersion *string `json:"agentVersion,omitempty"` + + // Azure VM resource ID + VMID *string `json:"vmId,omitempty"` +} diff --git a/sdk/resourcemanager/newrelic/armnewrelic/models_serde.go b/sdk/resourcemanager/newrelic/armnewrelic/models_serde.go new file mode 100644 index 000000000000..7c22d6352e82 --- /dev/null +++ b/sdk/resourcemanager/newrelic/armnewrelic/models_serde.go @@ -0,0 +1,1746 @@ +//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. +// DO NOT EDIT. + +package armnewrelic + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type AccountInfo. +func (a AccountInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "accountId", a.AccountID) + populate(objectMap, "ingestionKey", a.IngestionKey) + populate(objectMap, "region", a.Region) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AccountInfo. +func (a *AccountInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "accountId": + err = unpopulate(val, "AccountID", &a.AccountID) + delete(rawMsg, key) + case "ingestionKey": + err = unpopulate(val, "IngestionKey", &a.IngestionKey) + delete(rawMsg, key) + case "region": + err = unpopulate(val, "Region", &a.Region) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AccountProperties. +func (a AccountProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "accountId", a.AccountID) + populate(objectMap, "accountName", a.AccountName) + populate(objectMap, "organizationId", a.OrganizationID) + populate(objectMap, "region", a.Region) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AccountProperties. +func (a *AccountProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "accountId": + err = unpopulate(val, "AccountID", &a.AccountID) + delete(rawMsg, key) + case "accountName": + err = unpopulate(val, "AccountName", &a.AccountName) + delete(rawMsg, key) + case "organizationId": + err = unpopulate(val, "OrganizationID", &a.OrganizationID) + delete(rawMsg, key) + case "region": + err = unpopulate(val, "Region", &a.Region) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AccountPropertiesForNewRelic. +func (a AccountPropertiesForNewRelic) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "accountInfo", a.AccountInfo) + populate(objectMap, "organizationInfo", a.OrganizationInfo) + populate(objectMap, "singleSignOnProperties", a.SingleSignOnProperties) + populate(objectMap, "userId", a.UserID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AccountPropertiesForNewRelic. +func (a *AccountPropertiesForNewRelic) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "accountInfo": + err = unpopulate(val, "AccountInfo", &a.AccountInfo) + delete(rawMsg, key) + case "organizationInfo": + err = unpopulate(val, "OrganizationInfo", &a.OrganizationInfo) + delete(rawMsg, key) + case "singleSignOnProperties": + err = unpopulate(val, "SingleSignOnProperties", &a.SingleSignOnProperties) + delete(rawMsg, key) + case "userId": + err = unpopulate(val, "UserID", &a.UserID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AccountResource. +func (a AccountResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", a.ID) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "systemData", a.SystemData) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AccountResource. +func (a *AccountResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &a.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &a.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AccountsListResponse. +func (a AccountsListResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AccountsListResponse. +func (a *AccountsListResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &a.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &a.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AppServiceInfo. +func (a AppServiceInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "agentStatus", a.AgentStatus) + populate(objectMap, "agentVersion", a.AgentVersion) + populate(objectMap, "azureResourceId", a.AzureResourceID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AppServiceInfo. +func (a *AppServiceInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "agentStatus": + err = unpopulate(val, "AgentStatus", &a.AgentStatus) + delete(rawMsg, key) + case "agentVersion": + err = unpopulate(val, "AgentVersion", &a.AgentVersion) + delete(rawMsg, key) + case "azureResourceId": + err = unpopulate(val, "AzureResourceID", &a.AzureResourceID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AppServicesGetRequest. +func (a AppServicesGetRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "azureResourceIds", a.AzureResourceIDs) + populate(objectMap, "userEmail", a.UserEmail) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AppServicesGetRequest. +func (a *AppServicesGetRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "azureResourceIds": + err = unpopulate(val, "AzureResourceIDs", &a.AzureResourceIDs) + delete(rawMsg, key) + case "userEmail": + err = unpopulate(val, "UserEmail", &a.UserEmail) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AppServicesListResponse. +func (a AppServicesListResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AppServicesListResponse. +func (a *AppServicesListResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &a.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &a.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FilteringTag. +func (f FilteringTag) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "action", f.Action) + populate(objectMap, "name", f.Name) + populate(objectMap, "value", f.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FilteringTag. +func (f *FilteringTag) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "action": + err = unpopulate(val, "Action", &f.Action) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &f.Name) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &f.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HostsGetRequest. +func (h HostsGetRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "userEmail", h.UserEmail) + populate(objectMap, "vmIds", h.VMIDs) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HostsGetRequest. +func (h *HostsGetRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "userEmail": + err = unpopulate(val, "UserEmail", &h.UserEmail) + delete(rawMsg, key) + case "vmIds": + err = unpopulate(val, "VMIDs", &h.VMIDs) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type LogRules. +func (l LogRules) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "filteringTags", l.FilteringTags) + populate(objectMap, "sendAadLogs", l.SendAADLogs) + populate(objectMap, "sendActivityLogs", l.SendActivityLogs) + populate(objectMap, "sendSubscriptionLogs", l.SendSubscriptionLogs) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LogRules. +func (l *LogRules) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "filteringTags": + err = unpopulate(val, "FilteringTags", &l.FilteringTags) + delete(rawMsg, key) + case "sendAadLogs": + err = unpopulate(val, "SendAADLogs", &l.SendAADLogs) + delete(rawMsg, key) + case "sendActivityLogs": + err = unpopulate(val, "SendActivityLogs", &l.SendActivityLogs) + delete(rawMsg, key) + case "sendSubscriptionLogs": + err = unpopulate(val, "SendSubscriptionLogs", &l.SendSubscriptionLogs) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ManagedServiceIdentity. +func (m ManagedServiceIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "principalId", m.PrincipalID) + populate(objectMap, "tenantId", m.TenantID) + populate(objectMap, "type", m.Type) + populate(objectMap, "userAssignedIdentities", m.UserAssignedIdentities) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagedServiceIdentity. +func (m *ManagedServiceIdentity) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "principalId": + err = unpopulate(val, "PrincipalID", &m.PrincipalID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &m.TenantID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &m.Type) + delete(rawMsg, key) + case "userAssignedIdentities": + err = unpopulate(val, "UserAssignedIdentities", &m.UserAssignedIdentities) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MetricRules. +func (m MetricRules) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "filteringTags", m.FilteringTags) + populate(objectMap, "sendMetrics", m.SendMetrics) + populate(objectMap, "userEmail", m.UserEmail) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MetricRules. +func (m *MetricRules) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "filteringTags": + err = unpopulate(val, "FilteringTags", &m.FilteringTags) + delete(rawMsg, key) + case "sendMetrics": + err = unpopulate(val, "SendMetrics", &m.SendMetrics) + delete(rawMsg, key) + case "userEmail": + err = unpopulate(val, "UserEmail", &m.UserEmail) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MetricsRequest. +func (m MetricsRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "userEmail", m.UserEmail) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MetricsRequest. +func (m *MetricsRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "userEmail": + err = unpopulate(val, "UserEmail", &m.UserEmail) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MetricsStatusRequest. +func (m MetricsStatusRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "azureResourceIds", m.AzureResourceIDs) + populate(objectMap, "userEmail", m.UserEmail) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MetricsStatusRequest. +func (m *MetricsStatusRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "azureResourceIds": + err = unpopulate(val, "AzureResourceIDs", &m.AzureResourceIDs) + delete(rawMsg, key) + case "userEmail": + err = unpopulate(val, "UserEmail", &m.UserEmail) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MetricsStatusResponse. +func (m MetricsStatusResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "azureResourceIds", m.AzureResourceIDs) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MetricsStatusResponse. +func (m *MetricsStatusResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "azureResourceIds": + err = unpopulate(val, "AzureResourceIDs", &m.AzureResourceIDs) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MonitorProperties. +func (m MonitorProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "accountCreationSource", m.AccountCreationSource) + populate(objectMap, "liftrResourceCategory", m.LiftrResourceCategory) + populate(objectMap, "liftrResourcePreference", m.LiftrResourcePreference) + populate(objectMap, "marketplaceSubscriptionId", m.MarketplaceSubscriptionID) + populate(objectMap, "marketplaceSubscriptionStatus", m.MarketplaceSubscriptionStatus) + populate(objectMap, "monitoringStatus", m.MonitoringStatus) + populate(objectMap, "newRelicAccountProperties", m.NewRelicAccountProperties) + populate(objectMap, "orgCreationSource", m.OrgCreationSource) + populate(objectMap, "planData", m.PlanData) + populate(objectMap, "provisioningState", m.ProvisioningState) + populate(objectMap, "userInfo", m.UserInfo) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MonitorProperties. +func (m *MonitorProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "accountCreationSource": + err = unpopulate(val, "AccountCreationSource", &m.AccountCreationSource) + delete(rawMsg, key) + case "liftrResourceCategory": + err = unpopulate(val, "LiftrResourceCategory", &m.LiftrResourceCategory) + delete(rawMsg, key) + case "liftrResourcePreference": + err = unpopulate(val, "LiftrResourcePreference", &m.LiftrResourcePreference) + delete(rawMsg, key) + case "marketplaceSubscriptionId": + err = unpopulate(val, "MarketplaceSubscriptionID", &m.MarketplaceSubscriptionID) + delete(rawMsg, key) + case "marketplaceSubscriptionStatus": + err = unpopulate(val, "MarketplaceSubscriptionStatus", &m.MarketplaceSubscriptionStatus) + delete(rawMsg, key) + case "monitoringStatus": + err = unpopulate(val, "MonitoringStatus", &m.MonitoringStatus) + delete(rawMsg, key) + case "newRelicAccountProperties": + err = unpopulate(val, "NewRelicAccountProperties", &m.NewRelicAccountProperties) + delete(rawMsg, key) + case "orgCreationSource": + err = unpopulate(val, "OrgCreationSource", &m.OrgCreationSource) + delete(rawMsg, key) + case "planData": + err = unpopulate(val, "PlanData", &m.PlanData) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &m.ProvisioningState) + delete(rawMsg, key) + case "userInfo": + err = unpopulate(val, "UserInfo", &m.UserInfo) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MonitorResource. +func (m MonitorResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + 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) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MonitorResource. +func (m *MonitorResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &m.ID) + delete(rawMsg, key) + case "identity": + err = unpopulate(val, "Identity", &m.Identity) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &m.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &m.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &m.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &m.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &m.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &m.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MonitorResourceListResult. +func (m MonitorResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", m.NextLink) + populate(objectMap, "value", m.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MonitorResourceListResult. +func (m *MonitorResourceListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &m.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &m.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MonitorResourceUpdate. +func (m MonitorResourceUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "identity", m.Identity) + populate(objectMap, "properties", m.Properties) + populate(objectMap, "tags", m.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MonitorResourceUpdate. +func (m *MonitorResourceUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "identity": + err = unpopulate(val, "Identity", &m.Identity) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &m.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &m.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MonitorResourceUpdateProperties. +func (m MonitorResourceUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "accountCreationSource", m.AccountCreationSource) + populate(objectMap, "newRelicAccountProperties", m.NewRelicAccountProperties) + populate(objectMap, "orgCreationSource", m.OrgCreationSource) + populate(objectMap, "planData", m.PlanData) + populate(objectMap, "userInfo", m.UserInfo) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MonitorResourceUpdateProperties. +func (m *MonitorResourceUpdateProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "accountCreationSource": + err = unpopulate(val, "AccountCreationSource", &m.AccountCreationSource) + delete(rawMsg, key) + case "newRelicAccountProperties": + err = unpopulate(val, "NewRelicAccountProperties", &m.NewRelicAccountProperties) + delete(rawMsg, key) + case "orgCreationSource": + err = unpopulate(val, "OrgCreationSource", &m.OrgCreationSource) + delete(rawMsg, key) + case "planData": + err = unpopulate(val, "PlanData", &m.PlanData) + delete(rawMsg, key) + case "userInfo": + err = unpopulate(val, "UserInfo", &m.UserInfo) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MonitoredResource. +func (m MonitoredResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", m.ID) + populate(objectMap, "reasonForLogsStatus", m.ReasonForLogsStatus) + populate(objectMap, "reasonForMetricsStatus", m.ReasonForMetricsStatus) + populate(objectMap, "sendingLogs", m.SendingLogs) + populate(objectMap, "sendingMetrics", m.SendingMetrics) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MonitoredResource. +func (m *MonitoredResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &m.ID) + delete(rawMsg, key) + case "reasonForLogsStatus": + err = unpopulate(val, "ReasonForLogsStatus", &m.ReasonForLogsStatus) + delete(rawMsg, key) + case "reasonForMetricsStatus": + err = unpopulate(val, "ReasonForMetricsStatus", &m.ReasonForMetricsStatus) + delete(rawMsg, key) + case "sendingLogs": + err = unpopulate(val, "SendingLogs", &m.SendingLogs) + delete(rawMsg, key) + case "sendingMetrics": + err = unpopulate(val, "SendingMetrics", &m.SendingMetrics) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MonitoredResourceListResponse. +func (m MonitoredResourceListResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", m.NextLink) + populate(objectMap, "value", m.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MonitoredResourceListResponse. +func (m *MonitoredResourceListResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &m.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &m.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MonitoringTagRulesProperties. +func (m MonitoringTagRulesProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "logRules", m.LogRules) + populate(objectMap, "metricRules", m.MetricRules) + populate(objectMap, "provisioningState", m.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MonitoringTagRulesProperties. +func (m *MonitoringTagRulesProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "logRules": + err = unpopulate(val, "LogRules", &m.LogRules) + delete(rawMsg, key) + case "metricRules": + err = unpopulate(val, "MetricRules", &m.MetricRules) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &m.ProvisioningState) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actionType", o.ActionType) + populate(objectMap, "display", o.Display) + populate(objectMap, "isDataAction", o.IsDataAction) + populate(objectMap, "name", o.Name) + populate(objectMap, "origin", o.Origin) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "actionType": + err = unpopulate(val, "ActionType", &o.ActionType) + delete(rawMsg, key) + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "isDataAction": + err = unpopulate(val, "IsDataAction", &o.IsDataAction) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "origin": + err = unpopulate(val, "Origin", &o.Origin) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", o.Description) + populate(objectMap, "operation", o.Operation) + populate(objectMap, "provider", o.Provider) + populate(objectMap, "resource", o.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay. +func (o *OperationDisplay) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &o.Description) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &o.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &o.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &o.Resource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResult. +func (o *OperationListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &o.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &o.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OrganizationInfo. +func (o OrganizationInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "organizationId", o.OrganizationID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OrganizationInfo. +func (o *OrganizationInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "organizationId": + err = unpopulate(val, "OrganizationID", &o.OrganizationID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OrganizationProperties. +func (o OrganizationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "billingSource", o.BillingSource) + populate(objectMap, "organizationId", o.OrganizationID) + populate(objectMap, "organizationName", o.OrganizationName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OrganizationProperties. +func (o *OrganizationProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "billingSource": + err = unpopulate(val, "BillingSource", &o.BillingSource) + delete(rawMsg, key) + case "organizationId": + err = unpopulate(val, "OrganizationID", &o.OrganizationID) + delete(rawMsg, key) + case "organizationName": + err = unpopulate(val, "OrganizationName", &o.OrganizationName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OrganizationResource. +func (o OrganizationResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", o.ID) + populate(objectMap, "name", o.Name) + populate(objectMap, "properties", o.Properties) + populate(objectMap, "systemData", o.SystemData) + populate(objectMap, "type", o.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OrganizationResource. +func (o *OrganizationResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &o.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &o.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &o.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &o.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OrganizationsListResponse. +func (o OrganizationsListResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OrganizationsListResponse. +func (o *OrganizationsListResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &o.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &o.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PlanData. +func (p PlanData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + 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 fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "billingCycle": + err = unpopulate(val, "BillingCycle", &p.BillingCycle) + delete(rawMsg, key) + case "effectiveDate": + err = unpopulateTimeRFC3339(val, "EffectiveDate", &p.EffectiveDate) + delete(rawMsg, key) + case "planDetails": + err = unpopulate(val, "PlanDetails", &p.PlanDetails) + delete(rawMsg, key) + case "usageType": + err = unpopulate(val, "UsageType", &p.UsageType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PlanDataListResponse. +func (p PlanDataListResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PlanDataListResponse. +func (p *PlanDataListResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &p.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &p.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PlanDataProperties. +func (p PlanDataProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "accountCreationSource", p.AccountCreationSource) + populate(objectMap, "orgCreationSource", p.OrgCreationSource) + populate(objectMap, "planData", p.PlanData) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PlanDataProperties. +func (p *PlanDataProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "accountCreationSource": + err = unpopulate(val, "AccountCreationSource", &p.AccountCreationSource) + delete(rawMsg, key) + case "orgCreationSource": + err = unpopulate(val, "OrgCreationSource", &p.OrgCreationSource) + delete(rawMsg, key) + case "planData": + err = unpopulate(val, "PlanData", &p.PlanData) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PlanDataResource. +func (p PlanDataResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "systemData", p.SystemData) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PlanDataResource. +func (p *PlanDataResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &p.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SingleSignOnProperties. +func (s SingleSignOnProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "enterpriseAppId", s.EnterpriseAppID) + populate(objectMap, "provisioningState", s.ProvisioningState) + populate(objectMap, "singleSignOnState", s.SingleSignOnState) + populate(objectMap, "singleSignOnUrl", s.SingleSignOnURL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SingleSignOnProperties. +func (s *SingleSignOnProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "enterpriseAppId": + err = unpopulate(val, "EnterpriseAppID", &s.EnterpriseAppID) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &s.ProvisioningState) + delete(rawMsg, key) + case "singleSignOnState": + err = unpopulate(val, "SingleSignOnState", &s.SingleSignOnState) + delete(rawMsg, key) + case "singleSignOnUrl": + err = unpopulate(val, "SingleSignOnURL", &s.SingleSignOnURL) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SwitchBillingRequest. +func (s SwitchBillingRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "azureResourceId", s.AzureResourceID) + populate(objectMap, "organizationId", s.OrganizationID) + populate(objectMap, "planData", s.PlanData) + populate(objectMap, "userEmail", s.UserEmail) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SwitchBillingRequest. +func (s *SwitchBillingRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "azureResourceId": + err = unpopulate(val, "AzureResourceID", &s.AzureResourceID) + delete(rawMsg, key) + case "organizationId": + err = unpopulate(val, "OrganizationID", &s.OrganizationID) + delete(rawMsg, key) + case "planData": + err = unpopulate(val, "PlanData", &s.PlanData) + delete(rawMsg, key) + case "userEmail": + err = unpopulate(val, "UserEmail", &s.UserEmail) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + 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 fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TagRule. +func (t TagRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", t.ID) + populate(objectMap, "name", t.Name) + populate(objectMap, "properties", t.Properties) + populate(objectMap, "systemData", t.SystemData) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TagRule. +func (t *TagRule) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &t.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &t.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &t.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &t.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &t.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TagRuleListResult. +func (t TagRuleListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", t.NextLink) + populate(objectMap, "value", t.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TagRuleListResult. +func (t *TagRuleListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &t.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &t.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TagRuleUpdate. +func (t TagRuleUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", t.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TagRuleUpdate. +func (t *TagRuleUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &t.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TagRuleUpdateProperties. +func (t TagRuleUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "logRules", t.LogRules) + populate(objectMap, "metricRules", t.MetricRules) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TagRuleUpdateProperties. +func (t *TagRuleUpdateProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "logRules": + err = unpopulate(val, "LogRules", &t.LogRules) + delete(rawMsg, key) + case "metricRules": + err = unpopulate(val, "MetricRules", &t.MetricRules) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type UserAssignedIdentity. +func (u UserAssignedIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "clientId", u.ClientID) + populate(objectMap, "principalId", u.PrincipalID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UserAssignedIdentity. +func (u *UserAssignedIdentity) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "clientId": + err = unpopulate(val, "ClientID", &u.ClientID) + delete(rawMsg, key) + case "principalId": + err = unpopulate(val, "PrincipalID", &u.PrincipalID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type UserInfo. +func (u UserInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "country", u.Country) + populate(objectMap, "emailAddress", u.EmailAddress) + populate(objectMap, "firstName", u.FirstName) + populate(objectMap, "lastName", u.LastName) + populate(objectMap, "phoneNumber", u.PhoneNumber) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UserInfo. +func (u *UserInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "country": + err = unpopulate(val, "Country", &u.Country) + delete(rawMsg, key) + case "emailAddress": + err = unpopulate(val, "EmailAddress", &u.EmailAddress) + delete(rawMsg, key) + case "firstName": + err = unpopulate(val, "FirstName", &u.FirstName) + delete(rawMsg, key) + case "lastName": + err = unpopulate(val, "LastName", &u.LastName) + delete(rawMsg, key) + case "phoneNumber": + err = unpopulate(val, "PhoneNumber", &u.PhoneNumber) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VMExtensionPayload. +func (v VMExtensionPayload) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "ingestionKey", v.IngestionKey) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VMExtensionPayload. +func (v *VMExtensionPayload) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "ingestionKey": + err = unpopulate(val, "IngestionKey", &v.IngestionKey) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VMHostsListResponse. +func (v VMHostsListResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", v.NextLink) + populate(objectMap, "value", v.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VMHostsListResponse. +func (v *VMHostsListResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &v.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &v.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VMInfo. +func (v VMInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "agentStatus", v.AgentStatus) + populate(objectMap, "agentVersion", v.AgentVersion) + populate(objectMap, "vmId", v.VMID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VMInfo. +func (v *VMInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "agentStatus": + err = unpopulate(val, "AgentStatus", &v.AgentStatus) + delete(rawMsg, key) + case "agentVersion": + err = unpopulate(val, "AgentVersion", &v.AgentVersion) + delete(rawMsg, key) + case "vmId": + err = unpopulate(val, "VMID", &v.VMID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +func populate(m map[string]any, k string, v any) { + 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, fn string, v any) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/newrelic/armnewrelic/monitors_client.go b/sdk/resourcemanager/newrelic/armnewrelic/monitors_client.go new file mode 100644 index 000000000000..7c45bd2c207d --- /dev/null +++ b/sdk/resourcemanager/newrelic/armnewrelic/monitors_client.go @@ -0,0 +1,866 @@ +//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. +// DO NOT EDIT. + +package armnewrelic + +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.AzurePublic.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 NewRelicMonitorResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-07-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - monitorName - Name of the Monitors resource +// - 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) (*runtime.Poller[MonitorsClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, monitorName, resource, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[MonitorsClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[MonitorsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// CreateOrUpdate - Create a NewRelicMonitorResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-07-01-preview +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/NewRelic.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", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, resource) +} + +// BeginDelete - Delete a NewRelicMonitorResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-07-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - userEmail - User Email. +// - monitorName - Name of the Monitors resource +// - options - MonitorsClientBeginDeleteOptions contains the optional parameters for the MonitorsClient.BeginDelete method. +func (client *MonitorsClient) BeginDelete(ctx context.Context, resourceGroupName string, userEmail string, monitorName string, options *MonitorsClientBeginDeleteOptions) (*runtime.Poller[MonitorsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, userEmail, monitorName, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[MonitorsClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[MonitorsClientDeleteResponse](options.ResumeToken, client.pl, nil) + } +} + +// Delete - Delete a NewRelicMonitorResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-07-01-preview +func (client *MonitorsClient) deleteOperation(ctx context.Context, resourceGroupName string, userEmail string, monitorName string, options *MonitorsClientBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, userEmail, 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, userEmail string, monitorName string, options *MonitorsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/NewRelic.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", "2022-07-01-preview") + reqQP.Set("userEmail", userEmail) + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get a NewRelicMonitorResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-07-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - monitorName - Name of the Monitors resource +// - 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/NewRelic.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", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"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 +} + +// GetMetricRules - Get metric rules +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-07-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - monitorName - Name of the Monitors resource +// - request - The details of the get metrics status request. +// - options - MonitorsClientGetMetricRulesOptions contains the optional parameters for the MonitorsClient.GetMetricRules method. +func (client *MonitorsClient) GetMetricRules(ctx context.Context, resourceGroupName string, monitorName string, request MetricsRequest, options *MonitorsClientGetMetricRulesOptions) (MonitorsClientGetMetricRulesResponse, error) { + req, err := client.getMetricRulesCreateRequest(ctx, resourceGroupName, monitorName, request, options) + if err != nil { + return MonitorsClientGetMetricRulesResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return MonitorsClientGetMetricRulesResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return MonitorsClientGetMetricRulesResponse{}, runtime.NewResponseError(resp) + } + return client.getMetricRulesHandleResponse(resp) +} + +// getMetricRulesCreateRequest creates the GetMetricRules request. +func (client *MonitorsClient) getMetricRulesCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, request MetricsRequest, options *MonitorsClientGetMetricRulesOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/NewRelic.Observability/monitors/{monitorName}/getMetricRules" + 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", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, request) +} + +// getMetricRulesHandleResponse handles the GetMetricRules response. +func (client *MonitorsClient) getMetricRulesHandleResponse(resp *http.Response) (MonitorsClientGetMetricRulesResponse, error) { + result := MonitorsClientGetMetricRulesResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.MetricRules); err != nil { + return MonitorsClientGetMetricRulesResponse{}, err + } + return result, nil +} + +// GetMetricStatus - Get metric status +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-07-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - monitorName - Name of the Monitors resource +// - request - The details of the get metrics status request. +// - options - MonitorsClientGetMetricStatusOptions contains the optional parameters for the MonitorsClient.GetMetricStatus +// method. +func (client *MonitorsClient) GetMetricStatus(ctx context.Context, resourceGroupName string, monitorName string, request MetricsStatusRequest, options *MonitorsClientGetMetricStatusOptions) (MonitorsClientGetMetricStatusResponse, error) { + req, err := client.getMetricStatusCreateRequest(ctx, resourceGroupName, monitorName, request, options) + if err != nil { + return MonitorsClientGetMetricStatusResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return MonitorsClientGetMetricStatusResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return MonitorsClientGetMetricStatusResponse{}, runtime.NewResponseError(resp) + } + return client.getMetricStatusHandleResponse(resp) +} + +// getMetricStatusCreateRequest creates the GetMetricStatus request. +func (client *MonitorsClient) getMetricStatusCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, request MetricsStatusRequest, options *MonitorsClientGetMetricStatusOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/NewRelic.Observability/monitors/{monitorName}/getMetricStatus" + 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", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, request) +} + +// getMetricStatusHandleResponse handles the GetMetricStatus response. +func (client *MonitorsClient) getMetricStatusHandleResponse(resp *http.Response) (MonitorsClientGetMetricStatusResponse, error) { + result := MonitorsClientGetMetricStatusResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.MetricsStatusResponse); err != nil { + return MonitorsClientGetMetricStatusResponse{}, err + } + return result, nil +} + +// NewListAppServicesPager - List the app service resources currently being monitored by the NewRelic resource. +// +// Generated from API version 2022-07-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - monitorName - Name of the Monitors resource +// - request - The details of the app services get request. +// - options - MonitorsClientListAppServicesOptions contains the optional parameters for the MonitorsClient.NewListAppServicesPager +// method. +func (client *MonitorsClient) NewListAppServicesPager(resourceGroupName string, monitorName string, request AppServicesGetRequest, options *MonitorsClientListAppServicesOptions) *runtime.Pager[MonitorsClientListAppServicesResponse] { + return runtime.NewPager(runtime.PagingHandler[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, request, 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, request AppServicesGetRequest, options *MonitorsClientListAppServicesOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/NewRelic.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", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, request) +} + +// listAppServicesHandleResponse handles the ListAppServices response. +func (client *MonitorsClient) listAppServicesHandleResponse(resp *http.Response) (MonitorsClientListAppServicesResponse, error) { + result := MonitorsClientListAppServicesResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AppServicesListResponse); err != nil { + return MonitorsClientListAppServicesResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - List NewRelicMonitorResource resources by resource group +// +// Generated from API version 2022-07-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - MonitorsClientListByResourceGroupOptions contains the optional parameters for the MonitorsClient.NewListByResourceGroupPager +// method. +func (client *MonitorsClient) NewListByResourceGroupPager(resourceGroupName string, options *MonitorsClientListByResourceGroupOptions) *runtime.Pager[MonitorsClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[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/NewRelic.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", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"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 +} + +// NewListBySubscriptionPager - List NewRelicMonitorResource resources by subscription ID +// +// Generated from API version 2022-07-01-preview +// - options - MonitorsClientListBySubscriptionOptions contains the optional parameters for the MonitorsClient.NewListBySubscriptionPager +// method. +func (client *MonitorsClient) NewListBySubscriptionPager(options *MonitorsClientListBySubscriptionOptions) *runtime.Pager[MonitorsClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[MonitorsClientListBySubscriptionResponse]{ + More: func(page MonitorsClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *MonitorsClientListBySubscriptionResponse) (MonitorsClientListBySubscriptionResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listBySubscriptionCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return MonitorsClientListBySubscriptionResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return MonitorsClientListBySubscriptionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return MonitorsClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) + } + return client.listBySubscriptionHandleResponse(resp) + }, + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *MonitorsClient) listBySubscriptionCreateRequest(ctx context.Context, options *MonitorsClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/NewRelic.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", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *MonitorsClient) listBySubscriptionHandleResponse(resp *http.Response) (MonitorsClientListBySubscriptionResponse, error) { + result := MonitorsClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.MonitorResourceListResult); err != nil { + return MonitorsClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// NewListHostsPager - List the compute vm resources currently being monitored by the NewRelic resource. +// +// Generated from API version 2022-07-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - monitorName - Name of the Monitors resource +// - request - The details of the Hosts get request. +// - options - MonitorsClientListHostsOptions contains the optional parameters for the MonitorsClient.NewListHostsPager method. +func (client *MonitorsClient) NewListHostsPager(resourceGroupName string, monitorName string, request HostsGetRequest, options *MonitorsClientListHostsOptions) *runtime.Pager[MonitorsClientListHostsResponse] { + return runtime.NewPager(runtime.PagingHandler[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, request, 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, request HostsGetRequest, options *MonitorsClientListHostsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/NewRelic.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", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, request) +} + +// 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 +} + +// NewListMonitoredResourcesPager - List the resources currently being monitored by the NewRelic monitor resource. +// +// Generated from API version 2022-07-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - monitorName - Name of the Monitors resource +// - options - MonitorsClientListMonitoredResourcesOptions contains the optional parameters for the MonitorsClient.NewListMonitoredResourcesPager +// method. +func (client *MonitorsClient) NewListMonitoredResourcesPager(resourceGroupName string, monitorName string, options *MonitorsClientListMonitoredResourcesOptions) *runtime.Pager[MonitorsClientListMonitoredResourcesResponse] { + return runtime.NewPager(runtime.PagingHandler[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/NewRelic.Observability/monitors/{monitorName}/monitoredResources" + 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", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"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 +} + +// SwitchBilling - Switches the billing for NewRelic monitor resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-07-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - monitorName - Name of the Monitors resource +// - request - The details of the switch billing request. +// - options - MonitorsClientSwitchBillingOptions contains the optional parameters for the MonitorsClient.SwitchBilling method. +func (client *MonitorsClient) SwitchBilling(ctx context.Context, resourceGroupName string, monitorName string, request SwitchBillingRequest, options *MonitorsClientSwitchBillingOptions) (MonitorsClientSwitchBillingResponse, error) { + req, err := client.switchBillingCreateRequest(ctx, resourceGroupName, monitorName, request, options) + if err != nil { + return MonitorsClientSwitchBillingResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return MonitorsClientSwitchBillingResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusNoContent) { + return MonitorsClientSwitchBillingResponse{}, runtime.NewResponseError(resp) + } + return MonitorsClientSwitchBillingResponse{}, nil +} + +// switchBillingCreateRequest creates the SwitchBilling request. +func (client *MonitorsClient) switchBillingCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, request SwitchBillingRequest, options *MonitorsClientSwitchBillingOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/NewRelic.Observability/monitors/{monitorName}/switchBilling" + 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", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, request) +} + +// Update - Update a NewRelicMonitorResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-07-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - monitorName - Name of the Monitors resource +// - properties - 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, properties MonitorResourceUpdate, options *MonitorsClientUpdateOptions) (MonitorsClientUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, monitorName, properties, 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, properties MonitorResourceUpdate, options *MonitorsClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/NewRelic.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", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, properties) +} + +// 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 +} + +// VMHostPayload - Returns the payload that needs to be passed in the request body for installing NewRelic agent on a VM. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-07-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - monitorName - Name of the Monitors resource +// - options - MonitorsClientVMHostPayloadOptions contains the optional parameters for the MonitorsClient.VMHostPayload method. +func (client *MonitorsClient) VMHostPayload(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsClientVMHostPayloadOptions) (MonitorsClientVMHostPayloadResponse, error) { + req, err := client.vmHostPayloadCreateRequest(ctx, resourceGroupName, monitorName, options) + if err != nil { + return MonitorsClientVMHostPayloadResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return MonitorsClientVMHostPayloadResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return MonitorsClientVMHostPayloadResponse{}, runtime.NewResponseError(resp) + } + return client.vmHostPayloadHandleResponse(resp) +} + +// vmHostPayloadCreateRequest creates the VMHostPayload request. +func (client *MonitorsClient) vmHostPayloadCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsClientVMHostPayloadOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/NewRelic.Observability/monitors/{monitorName}/vmHostPayloads" + 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", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// vmHostPayloadHandleResponse handles the VMHostPayload response. +func (client *MonitorsClient) vmHostPayloadHandleResponse(resp *http.Response) (MonitorsClientVMHostPayloadResponse, error) { + result := MonitorsClientVMHostPayloadResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.VMExtensionPayload); err != nil { + return MonitorsClientVMHostPayloadResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/newrelic/armnewrelic/operations_client.go b/sdk/resourcemanager/newrelic/armnewrelic/operations_client.go new file mode 100644 index 000000000000..74200f0019ac --- /dev/null +++ b/sdk/resourcemanager/newrelic/armnewrelic/operations_client.go @@ -0,0 +1,105 @@ +//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. +// DO NOT EDIT. + +package armnewrelic + +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.AzurePublic.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 the provider +// +// Generated from API version 2022-07-01-preview +// - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[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/NewRelic.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", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"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/newrelic/armnewrelic/organizations_client.go b/sdk/resourcemanager/newrelic/armnewrelic/organizations_client.go new file mode 100644 index 000000000000..138ff656eecc --- /dev/null +++ b/sdk/resourcemanager/newrelic/armnewrelic/organizations_client.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. +// DO NOT EDIT. + +package armnewrelic + +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" +) + +// OrganizationsClient contains the methods for the Organizations group. +// Don't use this type directly, use NewOrganizationsClient() instead. +type OrganizationsClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewOrganizationsClient creates a new instance of OrganizationsClient 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 NewOrganizationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*OrganizationsClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.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 := &OrganizationsClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// NewListPager - List all the existing organizations +// +// Generated from API version 2022-07-01-preview +// - userEmail - User Email. +// - location - Location for NewRelic. +// - options - OrganizationsClientListOptions contains the optional parameters for the OrganizationsClient.NewListPager method. +func (client *OrganizationsClient) NewListPager(userEmail string, location string, options *OrganizationsClientListOptions) *runtime.Pager[OrganizationsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[OrganizationsClientListResponse]{ + More: func(page OrganizationsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *OrganizationsClientListResponse) (OrganizationsClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, userEmail, location, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return OrganizationsClientListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return OrganizationsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return OrganizationsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *OrganizationsClient) listCreateRequest(ctx context.Context, userEmail string, location string, options *OrganizationsClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/NewRelic.Observability/organizations" + 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", "2022-07-01-preview") + reqQP.Set("userEmail", userEmail) + reqQP.Set("location", location) + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OrganizationsClient) listHandleResponse(resp *http.Response) (OrganizationsClientListResponse, error) { + result := OrganizationsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.OrganizationsListResponse); err != nil { + return OrganizationsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/newrelic/armnewrelic/plans_client.go b/sdk/resourcemanager/newrelic/armnewrelic/plans_client.go new file mode 100644 index 000000000000..1937bbb21c71 --- /dev/null +++ b/sdk/resourcemanager/newrelic/armnewrelic/plans_client.go @@ -0,0 +1,121 @@ +//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. +// DO NOT EDIT. + +package armnewrelic + +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" +) + +// PlansClient contains the methods for the Plans group. +// Don't use this type directly, use NewPlansClient() instead. +type PlansClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewPlansClient creates a new instance of PlansClient 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 NewPlansClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PlansClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.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 := &PlansClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// NewListPager - List plans data +// +// Generated from API version 2022-07-01-preview +// - options - PlansClientListOptions contains the optional parameters for the PlansClient.NewListPager method. +func (client *PlansClient) NewListPager(options *PlansClientListOptions) *runtime.Pager[PlansClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[PlansClientListResponse]{ + More: func(page PlansClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *PlansClientListResponse) (PlansClientListResponse, 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 PlansClientListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PlansClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PlansClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *PlansClient) listCreateRequest(ctx context.Context, options *PlansClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/NewRelic.Observability/plans" + 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", "2022-07-01-preview") + if options != nil && options.AccountID != nil { + reqQP.Set("accountId", *options.AccountID) + } + if options != nil && options.OrganizationID != nil { + reqQP.Set("organizationId", *options.OrganizationID) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *PlansClient) listHandleResponse(resp *http.Response) (PlansClientListResponse, error) { + result := PlansClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PlanDataListResponse); err != nil { + return PlansClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/newrelic/armnewrelic/response_types.go b/sdk/resourcemanager/newrelic/armnewrelic/response_types.go new file mode 100644 index 000000000000..392518e0ef72 --- /dev/null +++ b/sdk/resourcemanager/newrelic/armnewrelic/response_types.go @@ -0,0 +1,120 @@ +//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. +// DO NOT EDIT. + +package armnewrelic + +// AccountsClientListResponse contains the response from method AccountsClient.NewListPager. +type AccountsClientListResponse struct { + AccountsListResponse +} + +// MonitorsClientCreateOrUpdateResponse contains the response from method MonitorsClient.BeginCreateOrUpdate. +type MonitorsClientCreateOrUpdateResponse struct { + MonitorResource +} + +// MonitorsClientDeleteResponse contains the response from method MonitorsClient.BeginDelete. +type MonitorsClientDeleteResponse struct { + // placeholder for future response values +} + +// MonitorsClientGetMetricRulesResponse contains the response from method MonitorsClient.GetMetricRules. +type MonitorsClientGetMetricRulesResponse struct { + MetricRules +} + +// MonitorsClientGetMetricStatusResponse contains the response from method MonitorsClient.GetMetricStatus. +type MonitorsClientGetMetricStatusResponse struct { + MetricsStatusResponse +} + +// MonitorsClientGetResponse contains the response from method MonitorsClient.Get. +type MonitorsClientGetResponse struct { + MonitorResource +} + +// MonitorsClientListAppServicesResponse contains the response from method MonitorsClient.NewListAppServicesPager. +type MonitorsClientListAppServicesResponse struct { + AppServicesListResponse +} + +// MonitorsClientListByResourceGroupResponse contains the response from method MonitorsClient.NewListByResourceGroupPager. +type MonitorsClientListByResourceGroupResponse struct { + MonitorResourceListResult +} + +// MonitorsClientListBySubscriptionResponse contains the response from method MonitorsClient.NewListBySubscriptionPager. +type MonitorsClientListBySubscriptionResponse struct { + MonitorResourceListResult +} + +// MonitorsClientListHostsResponse contains the response from method MonitorsClient.NewListHostsPager. +type MonitorsClientListHostsResponse struct { + VMHostsListResponse +} + +// MonitorsClientListMonitoredResourcesResponse contains the response from method MonitorsClient.NewListMonitoredResourcesPager. +type MonitorsClientListMonitoredResourcesResponse struct { + MonitoredResourceListResponse +} + +// MonitorsClientSwitchBillingResponse contains the response from method MonitorsClient.SwitchBilling. +type MonitorsClientSwitchBillingResponse struct { + // placeholder for future response values +} + +// MonitorsClientUpdateResponse contains the response from method MonitorsClient.Update. +type MonitorsClientUpdateResponse struct { + MonitorResource +} + +// MonitorsClientVMHostPayloadResponse contains the response from method MonitorsClient.VMHostPayload. +type MonitorsClientVMHostPayloadResponse struct { + VMExtensionPayload +} + +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. +type OperationsClientListResponse struct { + OperationListResult +} + +// OrganizationsClientListResponse contains the response from method OrganizationsClient.NewListPager. +type OrganizationsClientListResponse struct { + OrganizationsListResponse +} + +// PlansClientListResponse contains the response from method PlansClient.NewListPager. +type PlansClientListResponse struct { + PlanDataListResponse +} + +// TagRulesClientCreateOrUpdateResponse contains the response from method TagRulesClient.BeginCreateOrUpdate. +type TagRulesClientCreateOrUpdateResponse struct { + TagRule +} + +// TagRulesClientDeleteResponse contains the response from method TagRulesClient.BeginDelete. +type TagRulesClientDeleteResponse struct { + // placeholder for future response values +} + +// TagRulesClientGetResponse contains the response from method TagRulesClient.Get. +type TagRulesClientGetResponse struct { + TagRule +} + +// TagRulesClientListByNewRelicMonitorResourceResponse contains the response from method TagRulesClient.NewListByNewRelicMonitorResourcePager. +type TagRulesClientListByNewRelicMonitorResourceResponse struct { + TagRuleListResult +} + +// TagRulesClientUpdateResponse contains the response from method TagRulesClient.Update. +type TagRulesClientUpdateResponse struct { + TagRule +} diff --git a/sdk/resourcemanager/newrelic/armnewrelic/tagrules_client.go b/sdk/resourcemanager/newrelic/armnewrelic/tagrules_client.go new file mode 100644 index 000000000000..2a42ebf4a674 --- /dev/null +++ b/sdk/resourcemanager/newrelic/armnewrelic/tagrules_client.go @@ -0,0 +1,395 @@ +//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. +// DO NOT EDIT. + +package armnewrelic + +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.AzurePublic.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. +// +// Generated from API version 2022-07-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - monitorName - Name of the Monitors resource +// - ruleSetName - Name of the TagRule +// - 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) (*runtime.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 runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[TagRulesClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[TagRulesClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// CreateOrUpdate - Create a TagRule +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-07-01-preview +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/NewRelic.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", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, resource) +} + +// BeginDelete - Delete a TagRule +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-07-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - monitorName - Name of the Monitors resource +// - ruleSetName - Name of the TagRule +// - 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) (*runtime.Poller[TagRulesClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, monitorName, ruleSetName, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[TagRulesClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[TagRulesClientDeleteResponse](options.ResumeToken, client.pl, nil) + } +} + +// Delete - Delete a TagRule +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-07-01-preview +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/NewRelic.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", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get a TagRule +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-07-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - monitorName - Name of the Monitors resource +// - ruleSetName - Name of the TagRule +// - 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/NewRelic.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", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"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 +} + +// NewListByNewRelicMonitorResourcePager - List TagRule resources by NewRelicMonitorResource +// +// Generated from API version 2022-07-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - monitorName - Name of the Monitors resource +// - options - TagRulesClientListByNewRelicMonitorResourceOptions contains the optional parameters for the TagRulesClient.NewListByNewRelicMonitorResourcePager +// method. +func (client *TagRulesClient) NewListByNewRelicMonitorResourcePager(resourceGroupName string, monitorName string, options *TagRulesClientListByNewRelicMonitorResourceOptions) *runtime.Pager[TagRulesClientListByNewRelicMonitorResourceResponse] { + return runtime.NewPager(runtime.PagingHandler[TagRulesClientListByNewRelicMonitorResourceResponse]{ + More: func(page TagRulesClientListByNewRelicMonitorResourceResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *TagRulesClientListByNewRelicMonitorResourceResponse) (TagRulesClientListByNewRelicMonitorResourceResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByNewRelicMonitorResourceCreateRequest(ctx, resourceGroupName, monitorName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return TagRulesClientListByNewRelicMonitorResourceResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return TagRulesClientListByNewRelicMonitorResourceResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return TagRulesClientListByNewRelicMonitorResourceResponse{}, runtime.NewResponseError(resp) + } + return client.listByNewRelicMonitorResourceHandleResponse(resp) + }, + }) +} + +// listByNewRelicMonitorResourceCreateRequest creates the ListByNewRelicMonitorResource request. +func (client *TagRulesClient) listByNewRelicMonitorResourceCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, options *TagRulesClientListByNewRelicMonitorResourceOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/NewRelic.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", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByNewRelicMonitorResourceHandleResponse handles the ListByNewRelicMonitorResource response. +func (client *TagRulesClient) listByNewRelicMonitorResourceHandleResponse(resp *http.Response) (TagRulesClientListByNewRelicMonitorResourceResponse, error) { + result := TagRulesClientListByNewRelicMonitorResourceResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TagRuleListResult); err != nil { + return TagRulesClientListByNewRelicMonitorResourceResponse{}, err + } + return result, nil +} + +// Update - Update a TagRule +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-07-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - monitorName - Name of the Monitors resource +// - ruleSetName - Name of the TagRule +// - properties - 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, properties TagRuleUpdate, options *TagRulesClientUpdateOptions) (TagRulesClientUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, monitorName, ruleSetName, properties, 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, properties TagRuleUpdate, options *TagRulesClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/NewRelic.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", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, properties) +} + +// 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/newrelic/armnewrelic/time_rfc3339.go b/sdk/resourcemanager/newrelic/armnewrelic/time_rfc3339.go new file mode 100644 index 000000000000..e2d3ad56c6a4 --- /dev/null +++ b/sdk/resourcemanager/newrelic/armnewrelic/time_rfc3339.go @@ -0,0 +1,87 @@ +//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. +// DO NOT EDIT. + +package armnewrelic + +import ( + "encoding/json" + "fmt" + "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]any, 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, fn string, 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 fmt.Errorf("struct field %s: %v", fn, err) + } + *t = (*time.Time)(&aux) + return nil +}