diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/CHANGELOG.md b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/CHANGELOG.md index 44e75e516457..343a5f7d2380 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/CHANGELOG.md +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/CHANGELOG.md @@ -1,5 +1,56 @@ # Release History +## 0.8.0 (2023-01-28) +### Breaking Changes + +- Type of `AlertProperties.EgressConfig` has been changed from `interface{}` to `any` +- Type of `AlertProperties.Context` has been changed from `interface{}` to `any` +- Type of `AlertsClientChangeStateOptions.Comment` has been changed from `*string` to `*Comments` +- Type of `ErrorResponseAutoGenerated.Error` has been changed from `*ErrorResponseBodyAutoGenerated` to `*ErrorDetail` +- Type of `ErrorResponseAutoGenerated2.Error` has been changed from `*ErrorResponseBodyAutoGenerated2` to `*ErrorResponseBodyAutoGenerated` + +### Features Added + +- New type alias `MetricAlertsDisplayUnit` with values `MetricAlertsDisplayUnitBillion`, `MetricAlertsDisplayUnitBillionPerSecond`, `MetricAlertsDisplayUnitBytes`, `MetricAlertsDisplayUnitBytesPerDay`, `MetricAlertsDisplayUnitBytesPerHour`, `MetricAlertsDisplayUnitBytesPerMinute`, `MetricAlertsDisplayUnitBytesPerSecond`, `MetricAlertsDisplayUnitCount`, `MetricAlertsDisplayUnitCountPerDay`, `MetricAlertsDisplayUnitCountPerHour`, `MetricAlertsDisplayUnitCountPerMinute`, `MetricAlertsDisplayUnitCountPerSecond`, `MetricAlertsDisplayUnitDays`, `MetricAlertsDisplayUnitGigabytes`, `MetricAlertsDisplayUnitGigabytesPerSecond`, `MetricAlertsDisplayUnitHours`, `MetricAlertsDisplayUnitKilobytes`, `MetricAlertsDisplayUnitKilobytesPerSecond`, `MetricAlertsDisplayUnitMegabytes`, `MetricAlertsDisplayUnitMegabytesPerSecond`, `MetricAlertsDisplayUnitMicroSeconds`, `MetricAlertsDisplayUnitMilliSeconds`, `MetricAlertsDisplayUnitMillion`, `MetricAlertsDisplayUnitMillionPerSecond`, `MetricAlertsDisplayUnitMinutes`, `MetricAlertsDisplayUnitNone`, `MetricAlertsDisplayUnitPercentage`, `MetricAlertsDisplayUnitPetabytes`, `MetricAlertsDisplayUnitPetabytesPerSecond`, `MetricAlertsDisplayUnitSeconds`, `MetricAlertsDisplayUnitTerabytes`, `MetricAlertsDisplayUnitTerabytesPerSecond`, `MetricAlertsDisplayUnitThousand`, `MetricAlertsDisplayUnitThousandPerSecond`, `MetricAlertsDisplayUnitTrillion`, `MetricAlertsDisplayUnitTrillionPerSecond` +- New function `NewAlertRuleRecommendationsClient(string, string, azcore.TokenCredential, *arm.ClientOptions) (*AlertRuleRecommendationsClient, error)` +- New function `*AlertRuleRecommendationsClient.NewListByResourcePager(string, *AlertRuleRecommendationsClientListByResourceOptions) *runtime.Pager[AlertRuleRecommendationsClientListByResourceResponse]` +- New function `*AlertRuleRecommendationsClient.NewListByTargetTypePager(*AlertRuleRecommendationsClientListByTargetTypeOptions) *runtime.Pager[AlertRuleRecommendationsClientListByTargetTypeResponse]` +- New function `NewPrometheusRuleGroupsClient(string, azcore.TokenCredential, *arm.ClientOptions) (*PrometheusRuleGroupsClient, error)` +- New function `*PrometheusRuleGroupsClient.CreateOrUpdate(context.Context, string, string, PrometheusRuleGroupResource, *PrometheusRuleGroupsClientCreateOrUpdateOptions) (PrometheusRuleGroupsClientCreateOrUpdateResponse, error)` +- New function `*PrometheusRuleGroupsClient.Delete(context.Context, string, string, *PrometheusRuleGroupsClientDeleteOptions) (PrometheusRuleGroupsClientDeleteResponse, error)` +- New function `*PrometheusRuleGroupsClient.Get(context.Context, string, string, *PrometheusRuleGroupsClientGetOptions) (PrometheusRuleGroupsClientGetResponse, error)` +- New function `*PrometheusRuleGroupsClient.NewListByResourceGroupPager(string, *PrometheusRuleGroupsClientListByResourceGroupOptions) *runtime.Pager[PrometheusRuleGroupsClientListByResourceGroupResponse]` +- New function `*PrometheusRuleGroupsClient.NewListBySubscriptionPager(*PrometheusRuleGroupsClientListBySubscriptionOptions) *runtime.Pager[PrometheusRuleGroupsClientListBySubscriptionResponse]` +- New function `*PrometheusRuleGroupsClient.Update(context.Context, string, string, PrometheusRuleGroupResourcePatch, *PrometheusRuleGroupsClientUpdateOptions) (PrometheusRuleGroupsClientUpdateResponse, error)` +- New struct `AlertRuleRecommendationProperties` +- New struct `AlertRuleRecommendationResource` +- New struct `AlertRuleRecommendationsClient` +- New struct `AlertRuleRecommendationsClientListByResourceResponse` +- New struct `AlertRuleRecommendationsClientListByTargetTypeResponse` +- New struct `AlertRuleRecommendationsListResponse` +- New struct `Comments` +- New struct `DisplayInformationItem` +- New struct `ErrorAdditionalInfo` +- New struct `ErrorDetail` +- New struct `ErrorResponseAutoGenerated3` +- New struct `MetricAlertsDisplayInformation` +- New struct `PrometheusRule` +- New struct `PrometheusRuleGroupAction` +- New struct `PrometheusRuleGroupProperties` +- New struct `PrometheusRuleGroupResource` +- New struct `PrometheusRuleGroupResourceCollection` +- New struct `PrometheusRuleGroupResourcePatch` +- New struct `PrometheusRuleGroupResourcePatchProperties` +- New struct `PrometheusRuleGroupsClient` +- New struct `PrometheusRuleGroupsClientListByResourceGroupResponse` +- New struct `PrometheusRuleGroupsClientListBySubscriptionResponse` +- New struct `PrometheusRuleResolveConfiguration` +- New struct `ProxyResource` +- New struct `ResourceAutoGenerated` +- New struct `RuleArmTemplate` +- New struct `TrackedResource` + + ## 0.7.0 (2022-08-19) ### Features Added diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alertprocessingrules_client.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alertprocessingrules_client.go index 5a302afd0ca4..8f78462fdb52 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alertprocessingrules_client.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alertprocessingrules_client.go @@ -32,9 +32,9 @@ type AlertProcessingRulesClient struct { } // NewAlertProcessingRulesClient creates a new instance of AlertProcessingRulesClient 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. +// - 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 NewAlertProcessingRulesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AlertProcessingRulesClient, error) { if options == nil { options = &arm.ClientOptions{} @@ -57,12 +57,13 @@ func NewAlertProcessingRulesClient(subscriptionID string, credential azcore.Toke // CreateOrUpdate - Create or update an alert processing rule. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-08-08 -// resourceGroupName - Resource group name where the resource is created. -// alertProcessingRuleName - The name of the alert processing rule that needs to be created/updated. -// alertProcessingRule - Alert processing rule to be created/updated. -// options - AlertProcessingRulesClientCreateOrUpdateOptions contains the optional parameters for the AlertProcessingRulesClient.CreateOrUpdate -// method. +// - resourceGroupName - Resource group name where the resource is created. +// - alertProcessingRuleName - The name of the alert processing rule that needs to be created/updated. +// - alertProcessingRule - Alert processing rule to be created/updated. +// - options - AlertProcessingRulesClientCreateOrUpdateOptions contains the optional parameters for the AlertProcessingRulesClient.CreateOrUpdate +// method. func (client *AlertProcessingRulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, alertProcessingRuleName string, alertProcessingRule AlertProcessingRule, options *AlertProcessingRulesClientCreateOrUpdateOptions) (AlertProcessingRulesClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, alertProcessingRuleName, alertProcessingRule, options) if err != nil { @@ -118,11 +119,12 @@ func (client *AlertProcessingRulesClient) createOrUpdateHandleResponse(resp *htt // Delete - Delete an alert processing rule. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-08-08 -// resourceGroupName - Resource group name where the resource is created. -// alertProcessingRuleName - The name of the alert processing rule that needs to be deleted. -// options - AlertProcessingRulesClientDeleteOptions contains the optional parameters for the AlertProcessingRulesClient.Delete -// method. +// - resourceGroupName - Resource group name where the resource is created. +// - alertProcessingRuleName - The name of the alert processing rule that needs to be deleted. +// - options - AlertProcessingRulesClientDeleteOptions contains the optional parameters for the AlertProcessingRulesClient.Delete +// method. func (client *AlertProcessingRulesClient) Delete(ctx context.Context, resourceGroupName string, alertProcessingRuleName string, options *AlertProcessingRulesClientDeleteOptions) (AlertProcessingRulesClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, alertProcessingRuleName, options) if err != nil { @@ -175,11 +177,12 @@ func (client *AlertProcessingRulesClient) deleteHandleResponse(resp *http.Respon // GetByName - Get an alert processing rule by name. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-08-08 -// resourceGroupName - Resource group name where the resource is created. -// alertProcessingRuleName - The name of the alert processing rule that needs to be fetched. -// options - AlertProcessingRulesClientGetByNameOptions contains the optional parameters for the AlertProcessingRulesClient.GetByName -// method. +// - resourceGroupName - Resource group name where the resource is created. +// - alertProcessingRuleName - The name of the alert processing rule that needs to be fetched. +// - options - AlertProcessingRulesClientGetByNameOptions contains the optional parameters for the AlertProcessingRulesClient.GetByName +// method. func (client *AlertProcessingRulesClient) GetByName(ctx context.Context, resourceGroupName string, alertProcessingRuleName string, options *AlertProcessingRulesClientGetByNameOptions) (AlertProcessingRulesClientGetByNameResponse, error) { req, err := client.getByNameCreateRequest(ctx, resourceGroupName, alertProcessingRuleName, options) if err != nil { @@ -234,11 +237,11 @@ func (client *AlertProcessingRulesClient) getByNameHandleResponse(resp *http.Res } // NewListByResourceGroupPager - List all alert processing rules in a resource group. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-08-08 -// resourceGroupName - Resource group name where the resource is created. -// options - AlertProcessingRulesClientListByResourceGroupOptions contains the optional parameters for the AlertProcessingRulesClient.ListByResourceGroup -// method. +// - resourceGroupName - Resource group name where the resource is created. +// - options - AlertProcessingRulesClientListByResourceGroupOptions contains the optional parameters for the AlertProcessingRulesClient.NewListByResourceGroupPager +// method. func (client *AlertProcessingRulesClient) NewListByResourceGroupPager(resourceGroupName string, options *AlertProcessingRulesClientListByResourceGroupOptions) *runtime.Pager[AlertProcessingRulesClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[AlertProcessingRulesClientListByResourceGroupResponse]{ More: func(page AlertProcessingRulesClientListByResourceGroupResponse) bool { @@ -302,10 +305,10 @@ func (client *AlertProcessingRulesClient) listByResourceGroupHandleResponse(resp } // NewListBySubscriptionPager - List all alert processing rules in a subscription. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-08-08 -// options - AlertProcessingRulesClientListBySubscriptionOptions contains the optional parameters for the AlertProcessingRulesClient.ListBySubscription -// method. +// - options - AlertProcessingRulesClientListBySubscriptionOptions contains the optional parameters for the AlertProcessingRulesClient.NewListBySubscriptionPager +// method. func (client *AlertProcessingRulesClient) NewListBySubscriptionPager(options *AlertProcessingRulesClientListBySubscriptionOptions) *runtime.Pager[AlertProcessingRulesClientListBySubscriptionResponse] { return runtime.NewPager(runtime.PagingHandler[AlertProcessingRulesClientListBySubscriptionResponse]{ More: func(page AlertProcessingRulesClientListBySubscriptionResponse) bool { @@ -366,12 +369,13 @@ func (client *AlertProcessingRulesClient) listBySubscriptionHandleResponse(resp // Update - Enable, disable, or update tags for an alert processing rule. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-08-08 -// resourceGroupName - Resource group name where the resource is created. -// alertProcessingRuleName - The name that needs to be updated. -// alertProcessingRulePatch - Parameters supplied to the operation. -// options - AlertProcessingRulesClientUpdateOptions contains the optional parameters for the AlertProcessingRulesClient.Update -// method. +// - resourceGroupName - Resource group name where the resource is created. +// - alertProcessingRuleName - The name that needs to be updated. +// - alertProcessingRulePatch - Parameters supplied to the operation. +// - options - AlertProcessingRulesClientUpdateOptions contains the optional parameters for the AlertProcessingRulesClient.Update +// method. func (client *AlertProcessingRulesClient) Update(ctx context.Context, resourceGroupName string, alertProcessingRuleName string, alertProcessingRulePatch PatchObject, options *AlertProcessingRulesClientUpdateOptions) (AlertProcessingRulesClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, alertProcessingRuleName, alertProcessingRulePatch, options) if err != nil { diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alertprocessingrules_client_example_test.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alertprocessingrules_client_example_test.go deleted file mode 100644 index c5fe5e42f996..000000000000 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alertprocessingrules_client_example_test.go +++ /dev/null @@ -1,382 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armalertsmanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/alertsmanagement/armalertsmanagement" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/stable/2021-08-08/examples/AlertProcessingRules_List_Subscription.json -func ExampleAlertProcessingRulesClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armalertsmanagement.NewAlertProcessingRulesClient("1e3ff1c0-771a-4119-a03b-be82a51e232d", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListBySubscriptionPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/stable/2021-08-08/examples/AlertProcessingRules_List_ResourceGroup.json -func ExampleAlertProcessingRulesClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armalertsmanagement.NewAlertProcessingRulesClient("1e3ff1c0-771a-4119-a03b-be82a51e232d", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByResourceGroupPager("alertscorrelationrg", nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/stable/2021-08-08/examples/AlertProcessingRules_GetById.json -func ExampleAlertProcessingRulesClient_GetByName() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armalertsmanagement.NewAlertProcessingRulesClient("1e3ff1c0-771a-4119-a03b-be82a51e232d", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetByName(ctx, "alertscorrelationrg", "DailySuppression", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/stable/2021-08-08/examples/AlertProcessingRules_Create_or_update_add_action_group_all_alerts_in_subscription.json -func ExampleAlertProcessingRulesClient_CreateOrUpdate_createOrUpdateARuleThatAddsAnActionGroupToAllAlertsInASubscription() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armalertsmanagement.NewAlertProcessingRulesClient("subId1", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, "alertscorrelationrg", "AddActionGroupToSubscription", armalertsmanagement.AlertProcessingRule{ - Location: to.Ptr("Global"), - Tags: map[string]*string{}, - Properties: &armalertsmanagement.AlertProcessingRuleProperties{ - Description: to.Ptr("Add ActionGroup1 to all alerts in the subscription"), - Actions: []armalertsmanagement.ActionClassification{ - &armalertsmanagement.AddActionGroups{ - ActionType: to.Ptr(armalertsmanagement.ActionTypeAddActionGroups), - ActionGroupIDs: []*string{ - to.Ptr("/subscriptions/subId1/resourcegroups/RGId1/providers/microsoft.insights/actiongroups/ActionGroup1")}, - }}, - Enabled: to.Ptr(true), - Scopes: []*string{ - to.Ptr("/subscriptions/subId1")}, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/stable/2021-08-08/examples/AlertProcessingRules_Create_or_update_add_two_action_groups_all_Sev0_Sev1_two_resource_groups.json -func ExampleAlertProcessingRulesClient_CreateOrUpdate_createOrUpdateARuleThatAddsTwoActionGroupsToAllSev0AndSev1AlertsInTwoResourceGroups() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armalertsmanagement.NewAlertProcessingRulesClient("subId1", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, "alertscorrelationrg", "AddActionGroupsBySeverity", armalertsmanagement.AlertProcessingRule{ - Location: to.Ptr("Global"), - Tags: map[string]*string{}, - Properties: &armalertsmanagement.AlertProcessingRuleProperties{ - Description: to.Ptr("Add AGId1 and AGId2 to all Sev0 and Sev1 alerts in these resourceGroups"), - Actions: []armalertsmanagement.ActionClassification{ - &armalertsmanagement.AddActionGroups{ - ActionType: to.Ptr(armalertsmanagement.ActionTypeAddActionGroups), - ActionGroupIDs: []*string{ - to.Ptr("/subscriptions/subId1/resourcegroups/RGId1/providers/microsoft.insights/actiongroups/AGId1"), - to.Ptr("/subscriptions/subId1/resourcegroups/RGId1/providers/microsoft.insights/actiongroups/AGId2")}, - }}, - Conditions: []*armalertsmanagement.Condition{ - { - Field: to.Ptr(armalertsmanagement.FieldSeverity), - Operator: to.Ptr(armalertsmanagement.OperatorEquals), - Values: []*string{ - to.Ptr("sev0"), - to.Ptr("sev1")}, - }}, - Enabled: to.Ptr(true), - Scopes: []*string{ - to.Ptr("/subscriptions/subId1/resourceGroups/RGId1"), - to.Ptr("/subscriptions/subId1/resourceGroups/RGId2")}, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/stable/2021-08-08/examples/AlertProcessingRules_Create_or_update_remove_all_action_groups_specific_VM_one-off_maintenance_window.json -func ExampleAlertProcessingRulesClient_CreateOrUpdate_createOrUpdateARuleThatRemovesAllActionGroupsFromAlertsOnASpecificVmDuringAOneOffMaintenanceWindow18002000AtASpecificDatePacificStandardTime() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armalertsmanagement.NewAlertProcessingRulesClient("subId1", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, "alertscorrelationrg", "RemoveActionGroupsMaintenanceWindow", armalertsmanagement.AlertProcessingRule{ - Location: to.Ptr("Global"), - Tags: map[string]*string{}, - Properties: &armalertsmanagement.AlertProcessingRuleProperties{ - Description: to.Ptr("Removes all ActionGroups from all Alerts on VMName during the maintenance window"), - Actions: []armalertsmanagement.ActionClassification{ - &armalertsmanagement.RemoveAllActionGroups{ - ActionType: to.Ptr(armalertsmanagement.ActionTypeRemoveAllActionGroups), - }}, - Enabled: to.Ptr(true), - Schedule: &armalertsmanagement.Schedule{ - EffectiveFrom: to.Ptr("2021-04-15T18:00:00"), - EffectiveUntil: to.Ptr("2021-04-15T20:00:00"), - TimeZone: to.Ptr("Pacific Standard Time"), - }, - Scopes: []*string{ - to.Ptr("/subscriptions/subId1/resourceGroups/RGId1/providers/Microsoft.Compute/virtualMachines/VMName")}, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/stable/2021-08-08/examples/AlertProcessingRules_Create_or_update_remove_all_action_groups_from_specific_alert_rule.json -func ExampleAlertProcessingRulesClient_CreateOrUpdate_createOrUpdateARuleThatRemovesAllActionGroupsFromAllAlertsInASubscriptionComingFromASpecificAlertRule() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armalertsmanagement.NewAlertProcessingRulesClient("subId1", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, "alertscorrelationrg", "RemoveActionGroupsSpecificAlertRule", armalertsmanagement.AlertProcessingRule{ - Location: to.Ptr("Global"), - Tags: map[string]*string{}, - Properties: &armalertsmanagement.AlertProcessingRuleProperties{ - Description: to.Ptr("Removes all ActionGroups from all Alerts that fire on above AlertRule"), - Actions: []armalertsmanagement.ActionClassification{ - &armalertsmanagement.RemoveAllActionGroups{ - ActionType: to.Ptr(armalertsmanagement.ActionTypeRemoveAllActionGroups), - }}, - Conditions: []*armalertsmanagement.Condition{ - { - Field: to.Ptr(armalertsmanagement.FieldAlertRuleID), - Operator: to.Ptr(armalertsmanagement.OperatorEquals), - Values: []*string{ - to.Ptr("/subscriptions/suubId1/resourceGroups/Rgid2/providers/microsoft.insights/activityLogAlerts/RuleName")}, - }}, - Enabled: to.Ptr(true), - Scopes: []*string{ - to.Ptr("/subscriptions/subId1")}, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/stable/2021-08-08/examples/AlertProcessingRules_Create_or_update_remove_all_action_groups_recurring_maintenance_window.json -func ExampleAlertProcessingRulesClient_CreateOrUpdate_createOrUpdateARuleThatRemovesAllActionGroupsFromAllAlertsOnAnyVmInTwoResourceGroupsDuringARecurringMaintenanceWindow22000400EverySatAndSunIndiaStandardTime() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armalertsmanagement.NewAlertProcessingRulesClient("subId1", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, "alertscorrelationrg", "RemoveActionGroupsRecurringMaintenance", armalertsmanagement.AlertProcessingRule{ - Location: to.Ptr("Global"), - Tags: map[string]*string{}, - Properties: &armalertsmanagement.AlertProcessingRuleProperties{ - Description: to.Ptr("Remove all ActionGroups from all Vitual machine Alerts during the recurring maintenance"), - Actions: []armalertsmanagement.ActionClassification{ - &armalertsmanagement.RemoveAllActionGroups{ - ActionType: to.Ptr(armalertsmanagement.ActionTypeRemoveAllActionGroups), - }}, - Conditions: []*armalertsmanagement.Condition{ - { - Field: to.Ptr(armalertsmanagement.FieldTargetResourceType), - Operator: to.Ptr(armalertsmanagement.OperatorEquals), - Values: []*string{ - to.Ptr("microsoft.compute/virtualmachines")}, - }}, - Enabled: to.Ptr(true), - Schedule: &armalertsmanagement.Schedule{ - Recurrences: []armalertsmanagement.RecurrenceClassification{ - &armalertsmanagement.WeeklyRecurrence{ - EndTime: to.Ptr("04:00:00"), - RecurrenceType: to.Ptr(armalertsmanagement.RecurrenceTypeWeekly), - StartTime: to.Ptr("22:00:00"), - DaysOfWeek: []*armalertsmanagement.DaysOfWeek{ - to.Ptr(armalertsmanagement.DaysOfWeekSaturday), - to.Ptr(armalertsmanagement.DaysOfWeekSunday)}, - }}, - TimeZone: to.Ptr("India Standard Time"), - }, - Scopes: []*string{ - to.Ptr("/subscriptions/subId1/resourceGroups/RGId1"), - to.Ptr("/subscriptions/subId1/resourceGroups/RGId2")}, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/stable/2021-08-08/examples/AlertProcessingRules_Create_or_update_remove_all_action_groups_outside_business_hours.json -func ExampleAlertProcessingRulesClient_CreateOrUpdate_createOrUpdateARuleThatRemovesAllActionGroupsOutsideBusinessHoursMonFri09001700EasternStandardTime() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armalertsmanagement.NewAlertProcessingRulesClient("subId1", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, "alertscorrelationrg", "RemoveActionGroupsOutsideBusinessHours", armalertsmanagement.AlertProcessingRule{ - Location: to.Ptr("Global"), - Tags: map[string]*string{}, - Properties: &armalertsmanagement.AlertProcessingRuleProperties{ - Description: to.Ptr("Remove all ActionGroups outside business hours"), - Actions: []armalertsmanagement.ActionClassification{ - &armalertsmanagement.RemoveAllActionGroups{ - ActionType: to.Ptr(armalertsmanagement.ActionTypeRemoveAllActionGroups), - }}, - Enabled: to.Ptr(true), - Schedule: &armalertsmanagement.Schedule{ - Recurrences: []armalertsmanagement.RecurrenceClassification{ - &armalertsmanagement.DailyRecurrence{ - EndTime: to.Ptr("09:00:00"), - RecurrenceType: to.Ptr(armalertsmanagement.RecurrenceTypeDaily), - StartTime: to.Ptr("17:00:00"), - }, - &armalertsmanagement.WeeklyRecurrence{ - RecurrenceType: to.Ptr(armalertsmanagement.RecurrenceTypeWeekly), - DaysOfWeek: []*armalertsmanagement.DaysOfWeek{ - to.Ptr(armalertsmanagement.DaysOfWeekSaturday), - to.Ptr(armalertsmanagement.DaysOfWeekSunday)}, - }}, - TimeZone: to.Ptr("Eastern Standard Time"), - }, - Scopes: []*string{ - to.Ptr("/subscriptions/subId1")}, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/stable/2021-08-08/examples/AlertProcessingRules_Delete.json -func ExampleAlertProcessingRulesClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armalertsmanagement.NewAlertProcessingRulesClient("1e3ff1c0-771a-4119-a03b-be82a51e232d", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, "alertscorrelationrg", "DailySuppression", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/stable/2021-08-08/examples/AlertProcessingRules_Patch.json -func ExampleAlertProcessingRulesClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armalertsmanagement.NewAlertProcessingRulesClient("1e3ff1c0-771a-4119-a03b-be82a51e232d", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, "alertscorrelationrg", "WeeklySuppression", armalertsmanagement.PatchObject{ - Properties: &armalertsmanagement.PatchProperties{ - Enabled: to.Ptr(false), - }, - Tags: map[string]*string{ - "key1": to.Ptr("value1"), - "key2": to.Ptr("value2"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alertrulerecommendations_client.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alertrulerecommendations_client.go new file mode 100644 index 000000000000..35381cbe38f3 --- /dev/null +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alertrulerecommendations_client.go @@ -0,0 +1,178 @@ +//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 armalertsmanagement + +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" +) + +// AlertRuleRecommendationsClient contains the methods for the AlertRuleRecommendations group. +// Don't use this type directly, use NewAlertRuleRecommendationsClient() instead. +type AlertRuleRecommendationsClient struct { + host string + subscriptionID string + targetType string + pl runtime.Pipeline +} + +// NewAlertRuleRecommendationsClient creates a new instance of AlertRuleRecommendationsClient with the specified values. +// - subscriptionID - The ID of the target subscription. +// - targetType - The recommendations target type. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewAlertRuleRecommendationsClient(subscriptionID string, targetType string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AlertRuleRecommendationsClient, 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 := &AlertRuleRecommendationsClient{ + subscriptionID: subscriptionID, + targetType: targetType, + host: ep, + pl: pl, + } + return client, nil +} + +// NewListByResourcePager - Retrieve alert rule recommendations for a resource. +// +// Generated from API version 2023-01-01-preview +// - resourceURI - The identifier of the resource. +// - options - AlertRuleRecommendationsClientListByResourceOptions contains the optional parameters for the AlertRuleRecommendationsClient.NewListByResourcePager +// method. +func (client *AlertRuleRecommendationsClient) NewListByResourcePager(resourceURI string, options *AlertRuleRecommendationsClientListByResourceOptions) *runtime.Pager[AlertRuleRecommendationsClientListByResourceResponse] { + return runtime.NewPager(runtime.PagingHandler[AlertRuleRecommendationsClientListByResourceResponse]{ + More: func(page AlertRuleRecommendationsClientListByResourceResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *AlertRuleRecommendationsClientListByResourceResponse) (AlertRuleRecommendationsClientListByResourceResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByResourceCreateRequest(ctx, resourceURI, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return AlertRuleRecommendationsClientListByResourceResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AlertRuleRecommendationsClientListByResourceResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AlertRuleRecommendationsClientListByResourceResponse{}, runtime.NewResponseError(resp) + } + return client.listByResourceHandleResponse(resp) + }, + }) +} + +// listByResourceCreateRequest creates the ListByResource request. +func (client *AlertRuleRecommendationsClient) listByResourceCreateRequest(ctx context.Context, resourceURI string, options *AlertRuleRecommendationsClientListByResourceOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.AlertsManagement/alertRuleRecommendations" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + 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", "2023-01-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByResourceHandleResponse handles the ListByResource response. +func (client *AlertRuleRecommendationsClient) listByResourceHandleResponse(resp *http.Response) (AlertRuleRecommendationsClientListByResourceResponse, error) { + result := AlertRuleRecommendationsClientListByResourceResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AlertRuleRecommendationsListResponse); err != nil { + return AlertRuleRecommendationsClientListByResourceResponse{}, err + } + return result, nil +} + +// NewListByTargetTypePager - Retrieve alert rule recommendations for a target type. +// +// Generated from API version 2023-01-01-preview +// - options - AlertRuleRecommendationsClientListByTargetTypeOptions contains the optional parameters for the AlertRuleRecommendationsClient.NewListByTargetTypePager +// method. +func (client *AlertRuleRecommendationsClient) NewListByTargetTypePager(options *AlertRuleRecommendationsClientListByTargetTypeOptions) *runtime.Pager[AlertRuleRecommendationsClientListByTargetTypeResponse] { + return runtime.NewPager(runtime.PagingHandler[AlertRuleRecommendationsClientListByTargetTypeResponse]{ + More: func(page AlertRuleRecommendationsClientListByTargetTypeResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *AlertRuleRecommendationsClientListByTargetTypeResponse) (AlertRuleRecommendationsClientListByTargetTypeResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByTargetTypeCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return AlertRuleRecommendationsClientListByTargetTypeResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AlertRuleRecommendationsClientListByTargetTypeResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AlertRuleRecommendationsClientListByTargetTypeResponse{}, runtime.NewResponseError(resp) + } + return client.listByTargetTypeHandleResponse(resp) + }, + }) +} + +// listByTargetTypeCreateRequest creates the ListByTargetType request. +func (client *AlertRuleRecommendationsClient) listByTargetTypeCreateRequest(ctx context.Context, options *AlertRuleRecommendationsClientListByTargetTypeOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/alertRuleRecommendations" + 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", "2023-01-01-preview") + reqQP.Set("targetType", client.targetType) + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByTargetTypeHandleResponse handles the ListByTargetType response. +func (client *AlertRuleRecommendationsClient) listByTargetTypeHandleResponse(resp *http.Response) (AlertRuleRecommendationsClientListByTargetTypeResponse, error) { + result := AlertRuleRecommendationsClientListByTargetTypeResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AlertRuleRecommendationsListResponse); err != nil { + return AlertRuleRecommendationsClientListByTargetTypeResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alerts_client.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alerts_client.go index c5eafa7d29a3..107542c4ac8a 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alerts_client.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alerts_client.go @@ -18,7 +18,6 @@ import ( "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" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/streaming" "net/http" "net/url" "strconv" @@ -34,9 +33,9 @@ type AlertsClient struct { } // NewAlertsClient creates a new instance of AlertsClient 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. +// - 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 NewAlertsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AlertsClient, error) { if options == nil { options = &arm.ClientOptions{} @@ -59,10 +58,11 @@ func NewAlertsClient(subscriptionID string, credential azcore.TokenCredential, o // ChangeState - Change the state of an alert. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-05-05-preview -// alertID - Unique ID of an alert instance. -// newState - New state of the alert. -// options - AlertsClientChangeStateOptions contains the optional parameters for the AlertsClient.ChangeState method. +// - alertID - Unique ID of an alert instance. +// - newState - New state of the alert. +// - options - AlertsClientChangeStateOptions contains the optional parameters for the AlertsClient.ChangeState method. func (client *AlertsClient) ChangeState(ctx context.Context, alertID string, newState AlertState, options *AlertsClientChangeStateOptions) (AlertsClientChangeStateResponse, error) { req, err := client.changeStateCreateRequest(ctx, alertID, newState, options) if err != nil { @@ -99,8 +99,7 @@ func (client *AlertsClient) changeStateCreateRequest(ctx context.Context, alertI req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.Comment != nil { - body := streaming.NopCloser(strings.NewReader(*options.Comment)) - return req, req.SetBody(body, "application/json") + return req, runtime.MarshalAsJSON(req, *options.Comment) } return req, nil } @@ -117,9 +116,9 @@ func (client *AlertsClient) changeStateHandleResponse(resp *http.Response) (Aler // NewGetAllPager - List all existing alerts, where the results can be filtered on the basis of multiple parameters (e.g. // time range). The results can then be sorted on the basis specific fields, with the default being // lastModifiedDateTime. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-05-05-preview -// options - AlertsClientGetAllOptions contains the optional parameters for the AlertsClient.GetAll method. +// - options - AlertsClientGetAllOptions contains the optional parameters for the AlertsClient.NewGetAllPager method. func (client *AlertsClient) NewGetAllPager(options *AlertsClientGetAllOptions) *runtime.Pager[AlertsClientGetAllResponse] { return runtime.NewPager(runtime.PagingHandler[AlertsClientGetAllResponse]{ More: func(page AlertsClientGetAllResponse) bool { @@ -228,9 +227,10 @@ func (client *AlertsClient) getAllHandleResponse(resp *http.Response) (AlertsCli // GetByID - Get information related to a specific alert // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-05-05-preview -// alertID - Unique ID of an alert instance. -// options - AlertsClientGetByIDOptions contains the optional parameters for the AlertsClient.GetByID method. +// - alertID - Unique ID of an alert instance. +// - options - AlertsClientGetByIDOptions contains the optional parameters for the AlertsClient.GetByID method. func (client *AlertsClient) GetByID(ctx context.Context, alertID string, options *AlertsClientGetByIDOptions) (AlertsClientGetByIDResponse, error) { req, err := client.getByIDCreateRequest(ctx, alertID, options) if err != nil { @@ -280,9 +280,10 @@ func (client *AlertsClient) getByIDHandleResponse(resp *http.Response) (AlertsCl // GetHistory - Get the history of an alert, which captures any monitor condition changes (Fired/Resolved) and alert state // changes (New/Acknowledged/Closed). // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-05-05-preview -// alertID - Unique ID of an alert instance. -// options - AlertsClientGetHistoryOptions contains the optional parameters for the AlertsClient.GetHistory method. +// - alertID - Unique ID of an alert instance. +// - options - AlertsClientGetHistoryOptions contains the optional parameters for the AlertsClient.GetHistory method. func (client *AlertsClient) GetHistory(ctx context.Context, alertID string, options *AlertsClientGetHistoryOptions) (AlertsClientGetHistoryResponse, error) { req, err := client.getHistoryCreateRequest(ctx, alertID, options) if err != nil { @@ -332,10 +333,11 @@ func (client *AlertsClient) getHistoryHandleResponse(resp *http.Response) (Alert // GetSummary - Get a summarized count of your alerts grouped by various parameters (e.g. grouping by 'Severity' returns the // count of alerts for each severity). // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-05-05-preview -// groupby - This parameter allows the result set to be grouped by input fields (Maximum 2 comma separated fields supported). -// For example, groupby=severity or groupby=severity,alertstate. -// options - AlertsClientGetSummaryOptions contains the optional parameters for the AlertsClient.GetSummary method. +// - groupby - This parameter allows the result set to be grouped by input fields (Maximum 2 comma separated fields supported). +// For example, groupby=severity or groupby=severity,alertstate. +// - options - AlertsClientGetSummaryOptions contains the optional parameters for the AlertsClient.GetSummary method. func (client *AlertsClient) GetSummary(ctx context.Context, groupby AlertsSummaryGroupByFields, options *AlertsClientGetSummaryOptions) (AlertsClientGetSummaryResponse, error) { req, err := client.getSummaryCreateRequest(ctx, groupby, options) if err != nil { @@ -414,9 +416,10 @@ func (client *AlertsClient) getSummaryHandleResponse(resp *http.Response) (Alert // MetaData - List alerts meta data information based on value of identifier parameter. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-05-05-preview -// identifier - Identification of the information to be retrieved by API call. -// options - AlertsClientMetaDataOptions contains the optional parameters for the AlertsClient.MetaData method. +// - identifier - Identification of the information to be retrieved by API call. +// - options - AlertsClientMetaDataOptions contains the optional parameters for the AlertsClient.MetaData method. func (client *AlertsClient) MetaData(ctx context.Context, identifier Identifier, options *AlertsClientMetaDataOptions) (AlertsClientMetaDataResponse, error) { req, err := client.metaDataCreateRequest(ctx, identifier, options) if err != nil { diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alerts_client_example_test.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alerts_client_example_test.go deleted file mode 100644 index 521bab7f6648..000000000000 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alerts_client_example_test.go +++ /dev/null @@ -1,164 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armalertsmanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/alertsmanagement/armalertsmanagement" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2019-05-05-preview/examples/AlertsMetaData_MonitorService.json -func ExampleAlertsClient_MetaData() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armalertsmanagement.NewAlertsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.MetaData(ctx, armalertsmanagement.IdentifierMonitorServiceList, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2019-05-05-preview/examples/Alerts_List.json -func ExampleAlertsClient_NewGetAllPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armalertsmanagement.NewAlertsClient("1e3ff1c0-771a-4119-a03b-be82a51e232d", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewGetAllPager(&armalertsmanagement.AlertsClientGetAllOptions{TargetResource: nil, - TargetResourceType: nil, - TargetResourceGroup: nil, - MonitorService: nil, - MonitorCondition: nil, - Severity: nil, - AlertState: nil, - AlertRule: nil, - SmartGroupID: nil, - IncludeContext: nil, - IncludeEgressConfig: nil, - PageCount: nil, - SortBy: nil, - SortOrder: nil, - Select: nil, - TimeRange: nil, - CustomTimeRange: nil, - }) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2019-05-05-preview/examples/Alerts_GetById.json -func ExampleAlertsClient_GetByID() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armalertsmanagement.NewAlertsClient("9e261de7-c804-4b9d-9ebf-6f50fe350a9a", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetByID(ctx, "66114d64-d9d9-478b-95c9-b789d6502100", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2019-05-05-preview/examples/Alerts_ChangeState.json -func ExampleAlertsClient_ChangeState() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armalertsmanagement.NewAlertsClient("9e261de7-c804-4b9d-9ebf-6f50fe350a9a", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.ChangeState(ctx, "66114d64-d9d9-478b-95c9-b789d6502100", armalertsmanagement.AlertStateAcknowledged, &armalertsmanagement.AlertsClientChangeStateOptions{Comment: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2019-05-05-preview/examples/Alerts_History.json -func ExampleAlertsClient_GetHistory() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armalertsmanagement.NewAlertsClient("9e261de7-c804-4b9d-9ebf-6f50fe350a9a", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetHistory(ctx, "66114d64-d9d9-478b-95c9-b789d6502100", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2019-05-05-preview/examples/Alerts_Summary.json -func ExampleAlertsClient_GetSummary() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armalertsmanagement.NewAlertsClient("1e3ff1c0-771a-4119-a03b-be82a51e232d", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetSummary(ctx, armalertsmanagement.AlertsSummaryGroupByFields("severity,alertState"), &armalertsmanagement.AlertsClientGetSummaryOptions{IncludeSmartGroupsCount: nil, - TargetResource: nil, - TargetResourceType: nil, - TargetResourceGroup: nil, - MonitorService: nil, - MonitorCondition: nil, - Severity: nil, - AlertState: nil, - AlertRule: nil, - TimeRange: nil, - CustomTimeRange: nil, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/autorest.md b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/autorest.md index 5656b793d5c5..b2e01d65cd3e 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/autorest.md +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/autorest.md @@ -5,10 +5,10 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/a436672b07fb1fe276c203b086b3f0e0d0c4aa24/specification/alertsmanagement/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/a436672b07fb1fe276c203b086b3f0e0d0c4aa24/specification/alertsmanagement/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/alertsmanagement/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/alertsmanagement/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 0.7.0 +module-version: 0.8.0 modelerfour: lenient-model-deduplication: true ``` \ No newline at end of file diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/constants.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/constants.go index 369a5a99208f..9d037de0f460 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/constants.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/constants.go @@ -11,7 +11,7 @@ package armalertsmanagement const ( moduleName = "armalertsmanagement" - moduleVersion = "v0.7.0" + moduleVersion = "v0.8.0" ) // ActionType - Action that should be applied. @@ -238,6 +238,90 @@ func PossibleMetadataIdentifierValues() []MetadataIdentifier { } } +// MetricAlertsDisplayUnit - The unit to display for a metric alert rule. +type MetricAlertsDisplayUnit string + +const ( + MetricAlertsDisplayUnitBillion MetricAlertsDisplayUnit = "Billion" + MetricAlertsDisplayUnitBillionPerSecond MetricAlertsDisplayUnit = "BillionPerSecond" + MetricAlertsDisplayUnitBytes MetricAlertsDisplayUnit = "Bytes" + MetricAlertsDisplayUnitBytesPerDay MetricAlertsDisplayUnit = "BytesPerDay" + MetricAlertsDisplayUnitBytesPerHour MetricAlertsDisplayUnit = "BytesPerHour" + MetricAlertsDisplayUnitBytesPerMinute MetricAlertsDisplayUnit = "BytesPerMinute" + MetricAlertsDisplayUnitBytesPerSecond MetricAlertsDisplayUnit = "BytesPerSecond" + MetricAlertsDisplayUnitCount MetricAlertsDisplayUnit = "Count" + MetricAlertsDisplayUnitCountPerDay MetricAlertsDisplayUnit = "CountPerDay" + MetricAlertsDisplayUnitCountPerHour MetricAlertsDisplayUnit = "CountPerHour" + MetricAlertsDisplayUnitCountPerMinute MetricAlertsDisplayUnit = "CountPerMinute" + MetricAlertsDisplayUnitCountPerSecond MetricAlertsDisplayUnit = "CountPerSecond" + MetricAlertsDisplayUnitDays MetricAlertsDisplayUnit = "Days" + MetricAlertsDisplayUnitGigabytes MetricAlertsDisplayUnit = "Gigabytes" + MetricAlertsDisplayUnitGigabytesPerSecond MetricAlertsDisplayUnit = "GigabytesPerSecond" + MetricAlertsDisplayUnitHours MetricAlertsDisplayUnit = "Hours" + MetricAlertsDisplayUnitKilobytes MetricAlertsDisplayUnit = "Kilobytes" + MetricAlertsDisplayUnitKilobytesPerSecond MetricAlertsDisplayUnit = "KilobytesPerSecond" + MetricAlertsDisplayUnitMegabytes MetricAlertsDisplayUnit = "Megabytes" + MetricAlertsDisplayUnitMegabytesPerSecond MetricAlertsDisplayUnit = "MegabytesPerSecond" + MetricAlertsDisplayUnitMicroSeconds MetricAlertsDisplayUnit = "MicroSeconds" + MetricAlertsDisplayUnitMilliSeconds MetricAlertsDisplayUnit = "MilliSeconds" + MetricAlertsDisplayUnitMillion MetricAlertsDisplayUnit = "Million" + MetricAlertsDisplayUnitMillionPerSecond MetricAlertsDisplayUnit = "MillionPerSecond" + MetricAlertsDisplayUnitMinutes MetricAlertsDisplayUnit = "Minutes" + MetricAlertsDisplayUnitNone MetricAlertsDisplayUnit = "None" + MetricAlertsDisplayUnitPercentage MetricAlertsDisplayUnit = "Percentage" + MetricAlertsDisplayUnitPetabytes MetricAlertsDisplayUnit = "Petabytes" + MetricAlertsDisplayUnitPetabytesPerSecond MetricAlertsDisplayUnit = "PetabytesPerSecond" + MetricAlertsDisplayUnitSeconds MetricAlertsDisplayUnit = "Seconds" + MetricAlertsDisplayUnitTerabytes MetricAlertsDisplayUnit = "Terabytes" + MetricAlertsDisplayUnitTerabytesPerSecond MetricAlertsDisplayUnit = "TerabytesPerSecond" + MetricAlertsDisplayUnitThousand MetricAlertsDisplayUnit = "Thousand" + MetricAlertsDisplayUnitThousandPerSecond MetricAlertsDisplayUnit = "ThousandPerSecond" + MetricAlertsDisplayUnitTrillion MetricAlertsDisplayUnit = "Trillion" + MetricAlertsDisplayUnitTrillionPerSecond MetricAlertsDisplayUnit = "TrillionPerSecond" +) + +// PossibleMetricAlertsDisplayUnitValues returns the possible values for the MetricAlertsDisplayUnit const type. +func PossibleMetricAlertsDisplayUnitValues() []MetricAlertsDisplayUnit { + return []MetricAlertsDisplayUnit{ + MetricAlertsDisplayUnitBillion, + MetricAlertsDisplayUnitBillionPerSecond, + MetricAlertsDisplayUnitBytes, + MetricAlertsDisplayUnitBytesPerDay, + MetricAlertsDisplayUnitBytesPerHour, + MetricAlertsDisplayUnitBytesPerMinute, + MetricAlertsDisplayUnitBytesPerSecond, + MetricAlertsDisplayUnitCount, + MetricAlertsDisplayUnitCountPerDay, + MetricAlertsDisplayUnitCountPerHour, + MetricAlertsDisplayUnitCountPerMinute, + MetricAlertsDisplayUnitCountPerSecond, + MetricAlertsDisplayUnitDays, + MetricAlertsDisplayUnitGigabytes, + MetricAlertsDisplayUnitGigabytesPerSecond, + MetricAlertsDisplayUnitHours, + MetricAlertsDisplayUnitKilobytes, + MetricAlertsDisplayUnitKilobytesPerSecond, + MetricAlertsDisplayUnitMegabytes, + MetricAlertsDisplayUnitMegabytesPerSecond, + MetricAlertsDisplayUnitMicroSeconds, + MetricAlertsDisplayUnitMilliSeconds, + MetricAlertsDisplayUnitMillion, + MetricAlertsDisplayUnitMillionPerSecond, + MetricAlertsDisplayUnitMinutes, + MetricAlertsDisplayUnitNone, + MetricAlertsDisplayUnitPercentage, + MetricAlertsDisplayUnitPetabytes, + MetricAlertsDisplayUnitPetabytesPerSecond, + MetricAlertsDisplayUnitSeconds, + MetricAlertsDisplayUnitTerabytes, + MetricAlertsDisplayUnitTerabytesPerSecond, + MetricAlertsDisplayUnitThousand, + MetricAlertsDisplayUnitThousandPerSecond, + MetricAlertsDisplayUnitTrillion, + MetricAlertsDisplayUnitTrillionPerSecond, + } +} + type MonitorCondition string const ( diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/go.mod b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/go.mod index 7dd32ba6fe02..794db4908e3f 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/go.mod +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/go.mod @@ -2,20 +2,12 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/alertsmanagement/ar go 1.18 -require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0 -) +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/AzureAD/microsoft-authentication-library-for-go v0.5.1 // indirect - github.com/golang-jwt/jwt v3.2.1+incompatible // indirect - github.com/google/uuid v1.1.1 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect - golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect golang.org/x/text v0.3.7 // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect ) diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/go.sum b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/go.sum index 8828b17b1853..3afb578030a5 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/go.sum +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/go.sum @@ -1,33 +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/azidentity v1.1.0 h1:QkAcEIAKbNL4KoFr4SathZPhDhF4mVwpBMFlYjyAqy8= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0/go.mod h1:bhXu1AjYL+wutSL/kpSq6s7733q2Rb0yuot9Zgfqa/0= 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/AzureAD/microsoft-authentication-library-for-go v0.5.1 h1:BWe8a+f/t+7KY7zH2mqygeUD0t8hNFXe08p1Pb3/jKE= -github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= -github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= -github.com/golang-jwt/jwt/v4 v4.2.0 h1:besgBTC8w8HjP6NzQdxwKH9Z5oQMZ24ThTrHp3cZ8eU= -github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= +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/crypto v0.0.0-20220511200225-c6db032c6c88 h1:Tgea0cVUD0ivh5ADBX4WwuI12DUd2to3nCYe2eayMIw= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= 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/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 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/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +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/alertsmanagement/armalertsmanagement/models.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/models.go index 6a520e6aad5a..d47d9bd173a4 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/models.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/models.go @@ -177,13 +177,13 @@ type AlertProcessingRulesClientGetByNameOptions struct { // placeholder for future optional parameters } -// AlertProcessingRulesClientListByResourceGroupOptions contains the optional parameters for the AlertProcessingRulesClient.ListByResourceGroup +// AlertProcessingRulesClientListByResourceGroupOptions contains the optional parameters for the AlertProcessingRulesClient.NewListByResourceGroupPager // method. type AlertProcessingRulesClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// AlertProcessingRulesClientListBySubscriptionOptions contains the optional parameters for the AlertProcessingRulesClient.ListBySubscription +// AlertProcessingRulesClientListBySubscriptionOptions contains the optional parameters for the AlertProcessingRulesClient.NewListBySubscriptionPager // method. type AlertProcessingRulesClientListBySubscriptionOptions struct { // placeholder for future optional parameters @@ -209,19 +209,70 @@ type AlertProperties struct { Essentials *Essentials `json:"essentials,omitempty"` // READ-ONLY; Information specific to the monitor service that gives more contextual details about the alert. - Context interface{} `json:"context,omitempty" azure:"ro"` + Context any `json:"context,omitempty" azure:"ro"` // READ-ONLY; Config which would be used for displaying the data in portal. - EgressConfig interface{} `json:"egressConfig,omitempty" azure:"ro"` + EgressConfig any `json:"egressConfig,omitempty" azure:"ro"` +} + +// AlertRuleRecommendationProperties - Describes the format of Alert Rule Recommendations response. +type AlertRuleRecommendationProperties struct { + // REQUIRED; The recommendation alert rule type. + AlertRuleType *string `json:"alertRuleType,omitempty"` + + // REQUIRED; Provides the display information for an alert rule recommendation recommendations. + DisplayInformation *DisplayInformationItem `json:"displayInformation,omitempty"` + + // REQUIRED; A complete ARM template to deploy the alert rules. + RuleArmTemplate *RuleArmTemplate `json:"ruleArmTemplate,omitempty"` +} + +// AlertRuleRecommendationResource - A single alert rule recommendation resource. +type AlertRuleRecommendationResource struct { + // REQUIRED; recommendation properties. + Properties *AlertRuleRecommendationProperties `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"` +} + +// AlertRuleRecommendationsClientListByResourceOptions contains the optional parameters for the AlertRuleRecommendationsClient.NewListByResourcePager +// method. +type AlertRuleRecommendationsClientListByResourceOptions struct { + // placeholder for future optional parameters +} + +// AlertRuleRecommendationsClientListByTargetTypeOptions contains the optional parameters for the AlertRuleRecommendationsClient.NewListByTargetTypePager +// method. +type AlertRuleRecommendationsClientListByTargetTypeOptions struct { + // placeholder for future optional parameters +} + +// AlertRuleRecommendationsListResponse - List of alert rule recommendations. +type AlertRuleRecommendationsListResponse struct { + // REQUIRED; the values for the alert rule recommendations. + Value []*AlertRuleRecommendationResource `json:"value,omitempty"` + + // URL to fetch the next set of recommendations. + NextLink *string `json:"nextLink,omitempty"` } // AlertsClientChangeStateOptions contains the optional parameters for the AlertsClient.ChangeState method. type AlertsClientChangeStateOptions struct { // reason of change alert state - Comment *string + Comment *Comments } -// AlertsClientGetAllOptions contains the optional parameters for the AlertsClient.GetAll method. +// AlertsClientGetAllOptions contains the optional parameters for the AlertsClient.NewGetAllPager method. type AlertsClientGetAllOptions struct { // Filter by specific alert rule. Default value is to select all. AlertRule *string @@ -385,6 +436,11 @@ type AlertsSummaryGroupItem struct { Values []*AlertsSummaryGroupItem `json:"values,omitempty"` } +// Comments - Change alert state reason +type Comments struct { + Comments *string `json:"comments,omitempty"` +} + // Condition to trigger an alert processing rule. type Condition struct { // Field for a given condition. @@ -418,20 +474,69 @@ func (d *DailyRecurrence) GetRecurrence() *Recurrence { } } +// DisplayInformationItem - Provides the display information for an alert rule recommendation recommendations. +type DisplayInformationItem struct { + // The documentation link to display inside an information balloon. + InfoBallonLink *string `json:"infoBallonLink,omitempty"` + + // The information to display inside an information balloon. + InfoBallonMessage *string `json:"infoBallonMessage,omitempty"` + + // Provides display information specific for Metric Alerts rule. + MetricAlertsDisplayInformation *MetricAlertsDisplayInformation `json:"metricAlertsDisplayInformation,omitempty"` + + // The alert rule information. + RuleInfo *string `json:"ruleInfo,omitempty"` +} + +// ErrorAdditionalInfo - The resource management error additional info. +type ErrorAdditionalInfo struct { + // READ-ONLY; The additional info. + Info any `json:"info,omitempty" azure:"ro"` + + // READ-ONLY; The additional info type. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// ErrorDetail - The error detail. +type ErrorDetail struct { + // READ-ONLY; The error additional info. + AdditionalInfo []*ErrorAdditionalInfo `json:"additionalInfo,omitempty" azure:"ro"` + + // READ-ONLY; The error code. + Code *string `json:"code,omitempty" azure:"ro"` + + // READ-ONLY; The error details. + Details []*ErrorDetail `json:"details,omitempty" azure:"ro"` + + // READ-ONLY; The error message. + Message *string `json:"message,omitempty" azure:"ro"` + + // READ-ONLY; The error target. + Target *string `json:"target,omitempty" azure:"ro"` +} + // ErrorResponse - An error response from the service. type ErrorResponse struct { // Details of error response. Error *ErrorResponseBody `json:"error,omitempty"` } -// ErrorResponseAutoGenerated - An error response from the service. +// ErrorResponseAutoGenerated - Common error response for all Azure Resource Manager APIs to return error details for failed +// operations. (This also follows the OData error response format.). type ErrorResponseAutoGenerated struct { - // Details of error response. - Error *ErrorResponseBodyAutoGenerated `json:"error,omitempty"` + // The error object. + Error *ErrorDetail `json:"error,omitempty"` } // ErrorResponseAutoGenerated2 - An error response from the service. type ErrorResponseAutoGenerated2 struct { + // Details of error response. + Error *ErrorResponseBodyAutoGenerated `json:"error,omitempty"` +} + +// ErrorResponseAutoGenerated3 - An error response from the service. +type ErrorResponseAutoGenerated3 struct { // Details of error response. Error *ErrorResponseBodyAutoGenerated2 `json:"error,omitempty"` } @@ -564,6 +669,15 @@ type ManagedResource struct { Type *string `json:"type,omitempty" azure:"ro"` } +// MetricAlertsDisplayInformation - Provides display information specific for Metric Alerts rule. +type MetricAlertsDisplayInformation struct { + // REQUIRED; The display units to use in the UI for the metric alert rule. + DisplayUnits *MetricAlertsDisplayUnit `json:"displayUnits,omitempty"` + + // REQUIRED; The metric display name to use in the UI for the metric alert rule. + MetricDisplayName *string `json:"metricDisplayName,omitempty"` +} + // MonitorServiceDetails - Details of a monitor service type MonitorServiceDetails struct { // Monitor service display name @@ -640,7 +754,7 @@ type OperationDisplay struct { Resource *string `json:"resource,omitempty"` } -// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. type OperationsClientListOptions struct { // placeholder for future optional parameters } @@ -669,6 +783,172 @@ type PatchProperties struct { Enabled *bool `json:"enabled,omitempty"` } +type PrometheusRule struct { + // REQUIRED; the expression to run for the rule. + Expression *string `json:"expression,omitempty"` + + // The array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved. Only + // relevant for alerts. + Actions []*PrometheusRuleGroupAction `json:"actions,omitempty"` + + // the name of the alert rule. + Alert *string `json:"alert,omitempty"` + + // annotations for rule group. Only relevant for alerts. + Annotations map[string]*string `json:"annotations,omitempty"` + + // the flag that indicates whether the Prometheus rule is enabled. + Enabled *bool `json:"enabled,omitempty"` + + // the amount of time alert must be active before firing. Only relevant for alerts. + For *string `json:"for,omitempty"` + + // labels for rule group. Only relevant for alerts. + Labels map[string]*string `json:"labels,omitempty"` + + // the name of the recording rule. + Record *string `json:"record,omitempty"` + + // defines the configuration for resolving fired alerts. Only relevant for alerts. + ResolveConfiguration *PrometheusRuleResolveConfiguration `json:"resolveConfiguration,omitempty"` + + // the severity of the alerts fired by the rule. Only relevant for alerts. + Severity *int32 `json:"severity,omitempty"` +} + +// PrometheusRuleGroupAction - An alert action. Only relevant for alerts. +type PrometheusRuleGroupAction struct { + // The resource id of the action group to use. + ActionGroupID *string `json:"actionGroupId,omitempty"` + + // The properties of an action group object. + ActionProperties map[string]*string `json:"actionProperties,omitempty"` +} + +// PrometheusRuleGroupProperties - An alert rule. +type PrometheusRuleGroupProperties struct { + // REQUIRED; defines the rules in the Prometheus rule group. + Rules []*PrometheusRule `json:"rules,omitempty"` + + // REQUIRED; the list of resource id's that this rule group is scoped to. + Scopes []*string `json:"scopes,omitempty"` + + // the cluster name of the rule group evaluation. + ClusterName *string `json:"clusterName,omitempty"` + + // the description of the Prometheus rule group that will be included in the alert email. + Description *string `json:"description,omitempty"` + + // the flag that indicates whether the Prometheus rule group is enabled. + Enabled *bool `json:"enabled,omitempty"` + + // the interval in which to run the Prometheus rule group represented in ISO 8601 duration format. Should be between 1 and + // 15 minutes + Interval *string `json:"interval,omitempty"` +} + +// PrometheusRuleGroupResource - The Prometheus rule group resource. +type PrometheusRuleGroupResource struct { + // REQUIRED; The geo-location where the resource lives + Location *string `json:"location,omitempty"` + + // REQUIRED; The Prometheus rule group properties of the resource. + Properties *PrometheusRuleGroupProperties `json:"properties,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"` +} + +// PrometheusRuleGroupResourceCollection - Represents a collection of alert rule resources. +type PrometheusRuleGroupResourceCollection struct { + // the values for the alert rule resources. + Value []*PrometheusRuleGroupResource `json:"value,omitempty"` +} + +// PrometheusRuleGroupResourcePatch - The Prometheus rule group resource for patch operations. +type PrometheusRuleGroupResourcePatch struct { + Properties *PrometheusRuleGroupResourcePatchProperties `json:"properties,omitempty"` + + // Resource tags + Tags map[string]*string `json:"tags,omitempty"` +} + +type PrometheusRuleGroupResourcePatchProperties struct { + // the flag that indicates whether the Prometheus rule group is enabled. + Enabled *bool `json:"enabled,omitempty"` +} + +// PrometheusRuleGroupsClientCreateOrUpdateOptions contains the optional parameters for the PrometheusRuleGroupsClient.CreateOrUpdate +// method. +type PrometheusRuleGroupsClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// PrometheusRuleGroupsClientDeleteOptions contains the optional parameters for the PrometheusRuleGroupsClient.Delete method. +type PrometheusRuleGroupsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// PrometheusRuleGroupsClientGetOptions contains the optional parameters for the PrometheusRuleGroupsClient.Get method. +type PrometheusRuleGroupsClientGetOptions struct { + // placeholder for future optional parameters +} + +// PrometheusRuleGroupsClientListByResourceGroupOptions contains the optional parameters for the PrometheusRuleGroupsClient.NewListByResourceGroupPager +// method. +type PrometheusRuleGroupsClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// PrometheusRuleGroupsClientListBySubscriptionOptions contains the optional parameters for the PrometheusRuleGroupsClient.NewListBySubscriptionPager +// method. +type PrometheusRuleGroupsClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// PrometheusRuleGroupsClientUpdateOptions contains the optional parameters for the PrometheusRuleGroupsClient.Update method. +type PrometheusRuleGroupsClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// PrometheusRuleResolveConfiguration - Specifies the Prometheus alert rule configuration. +type PrometheusRuleResolveConfiguration struct { + // the flag that indicates whether or not to auto resolve a fired alert. + AutoResolved *bool `json:"autoResolved,omitempty"` + + // the duration a rule must evaluate as healthy before the fired alert is automatically resolved represented in ISO 8601 duration + // format. Should be between 1 and 15 minutes + TimeToResolve *string `json:"timeToResolve,omitempty"` +} + +// ProxyResource - The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a +// location +type ProxyResource struct { + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; 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"` +} + // RecurrenceClassification provides polymorphic access to related types. // Call the interface's GetRecurrence() method to access the common type. // Use a type switch to determine the concrete type. The possible types are: @@ -718,6 +998,39 @@ type Resource struct { Type *string `json:"type,omitempty" azure:"ro"` } +// ResourceAutoGenerated - Common fields that are returned in the response for all Azure Resource Manager resources +type ResourceAutoGenerated struct { + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; 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"` +} + +// RuleArmTemplate - A complete ARM template to deploy the alert rules. +type RuleArmTemplate struct { + // REQUIRED; A 4 number format for the version number of this template file. For example, 1.0.0.0 + ContentVersion *string `json:"contentVersion,omitempty"` + + // REQUIRED; Input parameter definitions + Parameters any `json:"parameters,omitempty"` + + // REQUIRED; Alert rule resource definitions + Resources []any `json:"resources,omitempty"` + + // REQUIRED; JSON schema reference + Schema *string `json:"$schema,omitempty"` + + // REQUIRED; Variable definitions + Variables any `json:"variables,omitempty"` +} + // Schedule - Scheduling configuration for a given alert processing rule. type Schedule struct { // Scheduling effective from time. Date-Time in ISO-8601 format without timezone suffix. @@ -858,7 +1171,7 @@ type SmartGroupsClientChangeStateOptions struct { // placeholder for future optional parameters } -// SmartGroupsClientGetAllOptions contains the optional parameters for the SmartGroupsClient.GetAll method. +// SmartGroupsClientGetAllOptions contains the optional parameters for the SmartGroupsClient.NewGetAllPager method. type SmartGroupsClientGetAllOptions struct { // Filter by monitor condition which is either 'Fired' or 'Resolved'. Default value is to select all. MonitorCondition *MonitorCondition @@ -925,6 +1238,28 @@ type SystemData struct { LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` } +// TrackedResource - The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' +// and a 'location' +type TrackedResource struct { + // REQUIRED; The geo-location where the resource lives + Location *string `json:"location,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; 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"` +} + // WeeklyRecurrence - Weekly recurrence object. type WeeklyRecurrence struct { // REQUIRED; Specifies the values for weekly recurrence pattern. diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/models_serde.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/models_serde.go index e33cb3a87eea..29605531c428 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/models_serde.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/models_serde.go @@ -18,7 +18,7 @@ import ( // MarshalJSON implements the json.Marshaller interface for type Action. func (a Action) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["actionType"] = a.ActionType return json.Marshal(objectMap) } @@ -45,7 +45,7 @@ func (a *Action) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ActionStatus. func (a ActionStatus) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "isSuppressed", a.IsSuppressed) return json.Marshal(objectMap) } @@ -72,7 +72,7 @@ func (a *ActionStatus) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AddActionGroups. func (a AddActionGroups) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "actionGroupIds", a.ActionGroupIDs) objectMap["actionType"] = ActionTypeAddActionGroups return json.Marshal(objectMap) @@ -103,7 +103,7 @@ func (a *AddActionGroups) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Alert. func (a Alert) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", a.ID) populate(objectMap, "name", a.Name) populate(objectMap, "properties", a.Properties) @@ -142,7 +142,7 @@ func (a *Alert) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AlertModification. func (a AlertModification) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", a.ID) populate(objectMap, "name", a.Name) populate(objectMap, "properties", a.Properties) @@ -181,7 +181,7 @@ func (a *AlertModification) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AlertModificationItem. func (a AlertModificationItem) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "comments", a.Comments) populate(objectMap, "description", a.Description) populate(objectMap, "modificationEvent", a.ModificationEvent) @@ -232,7 +232,7 @@ func (a *AlertModificationItem) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AlertModificationProperties. func (a AlertModificationProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "alertId", a.AlertID) populate(objectMap, "modifications", a.Modifications) return json.Marshal(objectMap) @@ -263,7 +263,7 @@ func (a *AlertModificationProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AlertProcessingRule. func (a AlertProcessingRule) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", a.ID) populate(objectMap, "location", a.Location) populate(objectMap, "name", a.Name) @@ -314,7 +314,7 @@ func (a *AlertProcessingRule) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AlertProcessingRuleProperties. func (a AlertProcessingRuleProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "actions", a.Actions) populate(objectMap, "conditions", a.Conditions) populate(objectMap, "description", a.Description) @@ -361,7 +361,7 @@ func (a *AlertProcessingRuleProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AlertProcessingRulesList. func (a AlertProcessingRulesList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", a.NextLink) populate(objectMap, "value", a.Value) return json.Marshal(objectMap) @@ -392,7 +392,7 @@ func (a *AlertProcessingRulesList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AlertProperties. func (a AlertProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "context", &a.Context) populate(objectMap, "egressConfig", &a.EgressConfig) populate(objectMap, "essentials", a.Essentials) @@ -425,9 +425,118 @@ func (a *AlertProperties) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type AlertRuleRecommendationProperties. +func (a AlertRuleRecommendationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "alertRuleType", a.AlertRuleType) + populate(objectMap, "displayInformation", a.DisplayInformation) + populate(objectMap, "ruleArmTemplate", a.RuleArmTemplate) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AlertRuleRecommendationProperties. +func (a *AlertRuleRecommendationProperties) 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 "alertRuleType": + err = unpopulate(val, "AlertRuleType", &a.AlertRuleType) + delete(rawMsg, key) + case "displayInformation": + err = unpopulate(val, "DisplayInformation", &a.DisplayInformation) + delete(rawMsg, key) + case "ruleArmTemplate": + err = unpopulate(val, "RuleArmTemplate", &a.RuleArmTemplate) + 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 AlertRuleRecommendationResource. +func (a AlertRuleRecommendationResource) 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 AlertRuleRecommendationResource. +func (a *AlertRuleRecommendationResource) 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 AlertRuleRecommendationsListResponse. +func (a AlertRuleRecommendationsListResponse) 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 AlertRuleRecommendationsListResponse. +func (a *AlertRuleRecommendationsListResponse) 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 AlertsList. func (a AlertsList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", a.NextLink) populate(objectMap, "value", a.Value) return json.Marshal(objectMap) @@ -458,7 +567,7 @@ func (a *AlertsList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AlertsMetaData. func (a AlertsMetaData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "properties", a.Properties) return json.Marshal(objectMap) } @@ -485,7 +594,7 @@ func (a *AlertsMetaData) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AlertsMetaDataProperties. func (a AlertsMetaDataProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["metadataIdentifier"] = a.MetadataIdentifier return json.Marshal(objectMap) } @@ -512,7 +621,7 @@ func (a *AlertsMetaDataProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AlertsSummary. func (a AlertsSummary) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", a.ID) populate(objectMap, "name", a.Name) populate(objectMap, "properties", a.Properties) @@ -551,7 +660,7 @@ func (a *AlertsSummary) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AlertsSummaryGroup. func (a AlertsSummaryGroup) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "groupedby", a.Groupedby) populate(objectMap, "smartGroupsCount", a.SmartGroupsCount) populate(objectMap, "total", a.Total) @@ -590,7 +699,7 @@ func (a *AlertsSummaryGroup) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AlertsSummaryGroupItem. func (a AlertsSummaryGroupItem) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "count", a.Count) populate(objectMap, "groupedby", a.Groupedby) populate(objectMap, "name", a.Name) @@ -627,9 +736,36 @@ func (a *AlertsSummaryGroupItem) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type Comments. +func (c Comments) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "comments", c.Comments) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Comments. +func (c *Comments) 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", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "comments": + err = unpopulate(val, "Comments", &c.Comments) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type Condition. func (c Condition) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "field", c.Field) populate(objectMap, "operator", c.Operator) populate(objectMap, "values", c.Values) @@ -664,7 +800,7 @@ func (c *Condition) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DailyRecurrence. func (d DailyRecurrence) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "endTime", d.EndTime) objectMap["recurrenceType"] = RecurrenceTypeDaily populate(objectMap, "startTime", d.StartTime) @@ -697,9 +833,122 @@ func (d *DailyRecurrence) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type DisplayInformationItem. +func (d DisplayInformationItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "infoBallonLink", d.InfoBallonLink) + populate(objectMap, "infoBallonMessage", d.InfoBallonMessage) + populate(objectMap, "metricAlertsDisplayInformation", d.MetricAlertsDisplayInformation) + populate(objectMap, "ruleInfo", d.RuleInfo) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DisplayInformationItem. +func (d *DisplayInformationItem) 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", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "infoBallonLink": + err = unpopulate(val, "InfoBallonLink", &d.InfoBallonLink) + delete(rawMsg, key) + case "infoBallonMessage": + err = unpopulate(val, "InfoBallonMessage", &d.InfoBallonMessage) + delete(rawMsg, key) + case "metricAlertsDisplayInformation": + err = unpopulate(val, "MetricAlertsDisplayInformation", &d.MetricAlertsDisplayInformation) + delete(rawMsg, key) + case "ruleInfo": + err = unpopulate(val, "RuleInfo", &d.RuleInfo) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorAdditionalInfo. +func (e ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "info", &e.Info) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorAdditionalInfo. +func (e *ErrorAdditionalInfo) 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", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "info": + err = unpopulate(val, "Info", &e.Info) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorDetail. +func (e ErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "additionalInfo", e.AdditionalInfo) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + populate(objectMap, "target", e.Target) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorDetail. +func (e *ErrorDetail) 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", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "additionalInfo": + err = unpopulate(val, "AdditionalInfo", &e.AdditionalInfo) + delete(rawMsg, key) + case "code": + err = unpopulate(val, "Code", &e.Code) + delete(rawMsg, key) + case "details": + err = unpopulate(val, "Details", &e.Details) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &e.Message) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &e.Target) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type ErrorResponse. func (e ErrorResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "error", e.Error) return json.Marshal(objectMap) } @@ -726,7 +975,7 @@ func (e *ErrorResponse) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ErrorResponseAutoGenerated. func (e ErrorResponseAutoGenerated) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "error", e.Error) return json.Marshal(objectMap) } @@ -753,7 +1002,7 @@ func (e *ErrorResponseAutoGenerated) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ErrorResponseAutoGenerated2. func (e ErrorResponseAutoGenerated2) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "error", e.Error) return json.Marshal(objectMap) } @@ -778,9 +1027,36 @@ func (e *ErrorResponseAutoGenerated2) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type ErrorResponseAutoGenerated3. +func (e ErrorResponseAutoGenerated3) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "error", e.Error) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponseAutoGenerated3. +func (e *ErrorResponseAutoGenerated3) 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", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "error": + err = unpopulate(val, "Error", &e.Error) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type ErrorResponseBody. func (e ErrorResponseBody) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "code", e.Code) populate(objectMap, "details", e.Details) populate(objectMap, "message", e.Message) @@ -819,7 +1095,7 @@ func (e *ErrorResponseBody) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ErrorResponseBodyAutoGenerated. func (e ErrorResponseBodyAutoGenerated) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "code", e.Code) populate(objectMap, "details", e.Details) populate(objectMap, "message", e.Message) @@ -858,7 +1134,7 @@ func (e *ErrorResponseBodyAutoGenerated) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ErrorResponseBodyAutoGenerated2. func (e ErrorResponseBodyAutoGenerated2) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "code", e.Code) populate(objectMap, "details", e.Details) populate(objectMap, "message", e.Message) @@ -897,7 +1173,7 @@ func (e *ErrorResponseBodyAutoGenerated2) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Essentials. func (e Essentials) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "actionStatus", e.ActionStatus) populate(objectMap, "alertRule", e.AlertRule) populate(objectMap, "alertState", e.AlertState) @@ -996,7 +1272,7 @@ func (e *Essentials) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ManagedResource. func (m ManagedResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", m.ID) populate(objectMap, "location", m.Location) populate(objectMap, "name", m.Name) @@ -1037,9 +1313,40 @@ func (m *ManagedResource) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type MetricAlertsDisplayInformation. +func (m MetricAlertsDisplayInformation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "displayUnits", m.DisplayUnits) + populate(objectMap, "metricDisplayName", m.MetricDisplayName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MetricAlertsDisplayInformation. +func (m *MetricAlertsDisplayInformation) 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 "displayUnits": + err = unpopulate(val, "DisplayUnits", &m.DisplayUnits) + delete(rawMsg, key) + case "metricDisplayName": + err = unpopulate(val, "MetricDisplayName", &m.MetricDisplayName) + 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 MonitorServiceDetails. func (m MonitorServiceDetails) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "displayName", m.DisplayName) populate(objectMap, "name", m.Name) return json.Marshal(objectMap) @@ -1070,7 +1377,7 @@ func (m *MonitorServiceDetails) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MonitorServiceList. func (m MonitorServiceList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "data", m.Data) objectMap["metadataIdentifier"] = MetadataIdentifierMonitorServiceList return json.Marshal(objectMap) @@ -1101,7 +1408,7 @@ func (m *MonitorServiceList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MonthlyRecurrence. func (m MonthlyRecurrence) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "daysOfMonth", m.DaysOfMonth) populate(objectMap, "endTime", m.EndTime) objectMap["recurrenceType"] = RecurrenceTypeMonthly @@ -1140,7 +1447,7 @@ func (m *MonthlyRecurrence) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Operation. func (o Operation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "display", o.Display) populate(objectMap, "name", o.Name) populate(objectMap, "origin", o.Origin) @@ -1175,7 +1482,7 @@ func (o *Operation) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OperationDisplay. func (o OperationDisplay) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", o.Description) populate(objectMap, "operation", o.Operation) populate(objectMap, "provider", o.Provider) @@ -1214,7 +1521,7 @@ func (o *OperationDisplay) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OperationsList. func (o OperationsList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", o.NextLink) populate(objectMap, "value", o.Value) return json.Marshal(objectMap) @@ -1245,7 +1552,7 @@ func (o *OperationsList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PatchObject. func (p PatchObject) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "properties", p.Properties) populate(objectMap, "tags", p.Tags) return json.Marshal(objectMap) @@ -1276,7 +1583,7 @@ func (p *PatchObject) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PatchProperties. func (p PatchProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "enabled", p.Enabled) return json.Marshal(objectMap) } @@ -1301,44 +1608,391 @@ func (p *PatchProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type Recurrence. -func (r Recurrence) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "endTime", r.EndTime) - objectMap["recurrenceType"] = r.RecurrenceType - populate(objectMap, "startTime", r.StartTime) +// MarshalJSON implements the json.Marshaller interface for type PrometheusRule. +func (p PrometheusRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actions", p.Actions) + populate(objectMap, "alert", p.Alert) + populate(objectMap, "annotations", p.Annotations) + populate(objectMap, "enabled", p.Enabled) + populate(objectMap, "expression", p.Expression) + populate(objectMap, "for", p.For) + populate(objectMap, "labels", p.Labels) + populate(objectMap, "record", p.Record) + populate(objectMap, "resolveConfiguration", p.ResolveConfiguration) + populate(objectMap, "severity", p.Severity) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type Recurrence. -func (r *Recurrence) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type PrometheusRule. +func (p *PrometheusRule) 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", r, err) + return fmt.Errorf("unmarshalling type %T: %v", p, err) } for key, val := range rawMsg { var err error switch key { - case "endTime": - err = unpopulate(val, "EndTime", &r.EndTime) + case "actions": + err = unpopulate(val, "Actions", &p.Actions) delete(rawMsg, key) - case "recurrenceType": - err = unpopulate(val, "RecurrenceType", &r.RecurrenceType) + case "alert": + err = unpopulate(val, "Alert", &p.Alert) delete(rawMsg, key) - case "startTime": - err = unpopulate(val, "StartTime", &r.StartTime) + case "annotations": + err = unpopulate(val, "Annotations", &p.Annotations) + delete(rawMsg, key) + case "enabled": + err = unpopulate(val, "Enabled", &p.Enabled) + delete(rawMsg, key) + case "expression": + err = unpopulate(val, "Expression", &p.Expression) + delete(rawMsg, key) + case "for": + err = unpopulate(val, "For", &p.For) + delete(rawMsg, key) + case "labels": + err = unpopulate(val, "Labels", &p.Labels) + delete(rawMsg, key) + case "record": + err = unpopulate(val, "Record", &p.Record) + delete(rawMsg, key) + case "resolveConfiguration": + err = unpopulate(val, "ResolveConfiguration", &p.ResolveConfiguration) + delete(rawMsg, key) + case "severity": + err = unpopulate(val, "Severity", &p.Severity) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", p, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type RemoveAllActionGroups. -func (r RemoveAllActionGroups) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) +// MarshalJSON implements the json.Marshaller interface for type PrometheusRuleGroupAction. +func (p PrometheusRuleGroupAction) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actionGroupId", p.ActionGroupID) + populate(objectMap, "actionProperties", p.ActionProperties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrometheusRuleGroupAction. +func (p *PrometheusRuleGroupAction) 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 "actionGroupId": + err = unpopulate(val, "ActionGroupID", &p.ActionGroupID) + delete(rawMsg, key) + case "actionProperties": + err = unpopulate(val, "ActionProperties", &p.ActionProperties) + 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 PrometheusRuleGroupProperties. +func (p PrometheusRuleGroupProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "clusterName", p.ClusterName) + populate(objectMap, "description", p.Description) + populate(objectMap, "enabled", p.Enabled) + populate(objectMap, "interval", p.Interval) + populate(objectMap, "rules", p.Rules) + populate(objectMap, "scopes", p.Scopes) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrometheusRuleGroupProperties. +func (p *PrometheusRuleGroupProperties) 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 "clusterName": + err = unpopulate(val, "ClusterName", &p.ClusterName) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &p.Description) + delete(rawMsg, key) + case "enabled": + err = unpopulate(val, "Enabled", &p.Enabled) + delete(rawMsg, key) + case "interval": + err = unpopulate(val, "Interval", &p.Interval) + delete(rawMsg, key) + case "rules": + err = unpopulate(val, "Rules", &p.Rules) + delete(rawMsg, key) + case "scopes": + err = unpopulate(val, "Scopes", &p.Scopes) + 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 PrometheusRuleGroupResource. +func (p PrometheusRuleGroupResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "location", p.Location) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "systemData", p.SystemData) + populate(objectMap, "tags", p.Tags) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrometheusRuleGroupResource. +func (p *PrometheusRuleGroupResource) 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 "location": + err = unpopulate(val, "Location", &p.Location) + 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 "tags": + err = unpopulate(val, "Tags", &p.Tags) + 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 PrometheusRuleGroupResourceCollection. +func (p PrometheusRuleGroupResourceCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrometheusRuleGroupResourceCollection. +func (p *PrometheusRuleGroupResourceCollection) 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 "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 PrometheusRuleGroupResourcePatch. +func (p PrometheusRuleGroupResourcePatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "tags", p.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrometheusRuleGroupResourcePatch. +func (p *PrometheusRuleGroupResourcePatch) 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 "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &p.Tags) + 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 PrometheusRuleGroupResourcePatchProperties. +func (p PrometheusRuleGroupResourcePatchProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "enabled", p.Enabled) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrometheusRuleGroupResourcePatchProperties. +func (p *PrometheusRuleGroupResourcePatchProperties) 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 "enabled": + err = unpopulate(val, "Enabled", &p.Enabled) + 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 PrometheusRuleResolveConfiguration. +func (p PrometheusRuleResolveConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "autoResolved", p.AutoResolved) + populate(objectMap, "timeToResolve", p.TimeToResolve) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrometheusRuleResolveConfiguration. +func (p *PrometheusRuleResolveConfiguration) 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 "autoResolved": + err = unpopulate(val, "AutoResolved", &p.AutoResolved) + delete(rawMsg, key) + case "timeToResolve": + err = unpopulate(val, "TimeToResolve", &p.TimeToResolve) + 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 ProxyResource. +func (p ProxyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "systemData", p.SystemData) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProxyResource. +func (p *ProxyResource) 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 "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 Recurrence. +func (r Recurrence) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "endTime", r.EndTime) + objectMap["recurrenceType"] = r.RecurrenceType + populate(objectMap, "startTime", r.StartTime) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Recurrence. +func (r *Recurrence) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "endTime": + err = unpopulate(val, "EndTime", &r.EndTime) + delete(rawMsg, key) + case "recurrenceType": + err = unpopulate(val, "RecurrenceType", &r.RecurrenceType) + delete(rawMsg, key) + case "startTime": + err = unpopulate(val, "StartTime", &r.StartTime) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RemoveAllActionGroups. +func (r RemoveAllActionGroups) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) objectMap["actionType"] = ActionTypeRemoveAllActionGroups return json.Marshal(objectMap) } @@ -1365,7 +2019,7 @@ func (r *RemoveAllActionGroups) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Resource. func (r Resource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", r.ID) populate(objectMap, "name", r.Name) populate(objectMap, "type", r.Type) @@ -1398,9 +2052,91 @@ func (r *Resource) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type ResourceAutoGenerated. +func (r ResourceAutoGenerated) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "systemData", r.SystemData) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceAutoGenerated. +func (r *ResourceAutoGenerated) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &r.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RuleArmTemplate. +func (r RuleArmTemplate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "contentVersion", r.ContentVersion) + populate(objectMap, "parameters", &r.Parameters) + populate(objectMap, "resources", r.Resources) + populate(objectMap, "$schema", r.Schema) + populate(objectMap, "variables", &r.Variables) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RuleArmTemplate. +func (r *RuleArmTemplate) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "contentVersion": + err = unpopulate(val, "ContentVersion", &r.ContentVersion) + delete(rawMsg, key) + case "parameters": + err = unpopulate(val, "Parameters", &r.Parameters) + delete(rawMsg, key) + case "resources": + err = unpopulate(val, "Resources", &r.Resources) + delete(rawMsg, key) + case "$schema": + err = unpopulate(val, "Schema", &r.Schema) + delete(rawMsg, key) + case "variables": + err = unpopulate(val, "Variables", &r.Variables) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type Schedule. func (s Schedule) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "effectiveFrom", s.EffectiveFrom) populate(objectMap, "effectiveUntil", s.EffectiveUntil) populate(objectMap, "recurrences", s.Recurrences) @@ -1439,7 +2175,7 @@ func (s *Schedule) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SmartGroup. func (s SmartGroup) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", s.ID) populate(objectMap, "name", s.Name) populate(objectMap, "properties", s.Properties) @@ -1478,7 +2214,7 @@ func (s *SmartGroup) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SmartGroupAggregatedProperty. func (s SmartGroupAggregatedProperty) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "count", s.Count) populate(objectMap, "name", s.Name) return json.Marshal(objectMap) @@ -1509,7 +2245,7 @@ func (s *SmartGroupAggregatedProperty) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SmartGroupModification. func (s SmartGroupModification) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", s.ID) populate(objectMap, "name", s.Name) populate(objectMap, "properties", s.Properties) @@ -1548,7 +2284,7 @@ func (s *SmartGroupModification) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SmartGroupModificationItem. func (s SmartGroupModificationItem) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "comments", s.Comments) populate(objectMap, "description", s.Description) populate(objectMap, "modificationEvent", s.ModificationEvent) @@ -1599,7 +2335,7 @@ func (s *SmartGroupModificationItem) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SmartGroupModificationProperties. func (s SmartGroupModificationProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "modifications", s.Modifications) populate(objectMap, "nextLink", s.NextLink) populate(objectMap, "smartGroupId", s.SmartGroupID) @@ -1634,7 +2370,7 @@ func (s *SmartGroupModificationProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SmartGroupProperties. func (s SmartGroupProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "alertSeverities", s.AlertSeverities) populate(objectMap, "alertStates", s.AlertStates) populate(objectMap, "alertsCount", s.AlertsCount) @@ -1713,7 +2449,7 @@ func (s *SmartGroupProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SmartGroupsList. func (s SmartGroupsList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", s.NextLink) populate(objectMap, "value", s.Value) return json.Marshal(objectMap) @@ -1744,7 +2480,7 @@ func (s *SmartGroupsList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SystemData. func (s SystemData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) populate(objectMap, "createdBy", s.CreatedBy) populate(objectMap, "createdByType", s.CreatedByType) @@ -1789,9 +2525,56 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type TrackedResource. +func (t TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", t.ID) + populate(objectMap, "location", t.Location) + populate(objectMap, "name", t.Name) + populate(objectMap, "systemData", t.SystemData) + populate(objectMap, "tags", t.Tags) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TrackedResource. +func (t *TrackedResource) 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 "location": + err = unpopulate(val, "Location", &t.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &t.Name) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &t.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &t.Tags) + 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 WeeklyRecurrence. func (w WeeklyRecurrence) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "daysOfWeek", w.DaysOfWeek) populate(objectMap, "endTime", w.EndTime) objectMap["recurrenceType"] = RecurrenceTypeWeekly @@ -1828,7 +2611,7 @@ func (w *WeeklyRecurrence) UnmarshalJSON(data []byte) error { return nil } -func populate(m map[string]interface{}, k string, v interface{}) { +func populate(m map[string]any, k string, v any) { if v == nil { return } else if azcore.IsNullValue(v) { @@ -1838,7 +2621,7 @@ func populate(m map[string]interface{}, k string, v interface{}) { } } -func unpopulate(data json.RawMessage, fn string, v interface{}) error { +func unpopulate(data json.RawMessage, fn string, v any) error { if data == nil { return nil } diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/operations_client.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/operations_client.go index 12b4b8f086f2..59267c24c9e1 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/operations_client.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/operations_client.go @@ -28,8 +28,8 @@ type OperationsClient struct { } // 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. +// - 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{} @@ -50,9 +50,9 @@ func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientO } // NewListPager - List all operations available through Azure Alerts Management Resource Provider. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-05-05-preview -// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// - 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 { diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/operations_client_example_test.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/operations_client_example_test.go deleted file mode 100644 index 9cd4540bf015..000000000000 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/operations_client_example_test.go +++ /dev/null @@ -1,41 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armalertsmanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/alertsmanagement/armalertsmanagement" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2019-05-05-preview/examples/Operations_List.json -func ExampleOperationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armalertsmanagement.NewOperationsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/polymorphic_helpers.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/polymorphic_helpers.go index 5b687932572b..c2e3e45a7656 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/polymorphic_helpers.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/polymorphic_helpers.go @@ -15,7 +15,7 @@ func unmarshalActionClassification(rawMsg json.RawMessage) (ActionClassification if rawMsg == nil { return nil, nil } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } @@ -54,7 +54,7 @@ func unmarshalAlertsMetaDataPropertiesClassification(rawMsg json.RawMessage) (Al if rawMsg == nil { return nil, nil } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } @@ -72,7 +72,7 @@ func unmarshalRecurrenceClassification(rawMsg json.RawMessage) (RecurrenceClassi if rawMsg == nil { return nil, nil } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/prometheusrulegroups_client.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/prometheusrulegroups_client.go new file mode 100644 index 000000000000..870688f87f7b --- /dev/null +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/prometheusrulegroups_client.go @@ -0,0 +1,394 @@ +//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 armalertsmanagement + +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" +) + +// PrometheusRuleGroupsClient contains the methods for the PrometheusRuleGroups group. +// Don't use this type directly, use NewPrometheusRuleGroupsClient() instead. +type PrometheusRuleGroupsClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewPrometheusRuleGroupsClient creates a new instance of PrometheusRuleGroupsClient 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 NewPrometheusRuleGroupsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PrometheusRuleGroupsClient, 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 := &PrometheusRuleGroupsClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// CreateOrUpdate - Create or update a Prometheus rule group definition. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-07-22-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - ruleGroupName - The name of the rule group. +// - parameters - The parameters of the rule group to create or update. +// - options - PrometheusRuleGroupsClientCreateOrUpdateOptions contains the optional parameters for the PrometheusRuleGroupsClient.CreateOrUpdate +// method. +func (client *PrometheusRuleGroupsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, ruleGroupName string, parameters PrometheusRuleGroupResource, options *PrometheusRuleGroupsClientCreateOrUpdateOptions) (PrometheusRuleGroupsClientCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, ruleGroupName, parameters, options) + if err != nil { + return PrometheusRuleGroupsClientCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrometheusRuleGroupsClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return PrometheusRuleGroupsClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *PrometheusRuleGroupsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, ruleGroupName string, parameters PrometheusRuleGroupResource, options *PrometheusRuleGroupsClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/prometheusRuleGroups/{ruleGroupName}" + 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 ruleGroupName == "" { + return nil, errors.New("parameter ruleGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{ruleGroupName}", url.PathEscape(ruleGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-07-22-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *PrometheusRuleGroupsClient) createOrUpdateHandleResponse(resp *http.Response) (PrometheusRuleGroupsClientCreateOrUpdateResponse, error) { + result := PrometheusRuleGroupsClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PrometheusRuleGroupResource); err != nil { + return PrometheusRuleGroupsClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Delete a Prometheus rule group definition. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-07-22-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - ruleGroupName - The name of the rule group. +// - options - PrometheusRuleGroupsClientDeleteOptions contains the optional parameters for the PrometheusRuleGroupsClient.Delete +// method. +func (client *PrometheusRuleGroupsClient) Delete(ctx context.Context, resourceGroupName string, ruleGroupName string, options *PrometheusRuleGroupsClientDeleteOptions) (PrometheusRuleGroupsClientDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, ruleGroupName, options) + if err != nil { + return PrometheusRuleGroupsClientDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrometheusRuleGroupsClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return PrometheusRuleGroupsClientDeleteResponse{}, runtime.NewResponseError(resp) + } + return PrometheusRuleGroupsClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *PrometheusRuleGroupsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, ruleGroupName string, options *PrometheusRuleGroupsClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/prometheusRuleGroups/{ruleGroupName}" + 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 ruleGroupName == "" { + return nil, errors.New("parameter ruleGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{ruleGroupName}", url.PathEscape(ruleGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-07-22-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Retrieve a Prometheus rule group definition. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-07-22-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - ruleGroupName - The name of the rule group. +// - options - PrometheusRuleGroupsClientGetOptions contains the optional parameters for the PrometheusRuleGroupsClient.Get +// method. +func (client *PrometheusRuleGroupsClient) Get(ctx context.Context, resourceGroupName string, ruleGroupName string, options *PrometheusRuleGroupsClientGetOptions) (PrometheusRuleGroupsClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, ruleGroupName, options) + if err != nil { + return PrometheusRuleGroupsClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrometheusRuleGroupsClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PrometheusRuleGroupsClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *PrometheusRuleGroupsClient) getCreateRequest(ctx context.Context, resourceGroupName string, ruleGroupName string, options *PrometheusRuleGroupsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/prometheusRuleGroups/{ruleGroupName}" + 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 ruleGroupName == "" { + return nil, errors.New("parameter ruleGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{ruleGroupName}", url.PathEscape(ruleGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-07-22-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *PrometheusRuleGroupsClient) getHandleResponse(resp *http.Response) (PrometheusRuleGroupsClientGetResponse, error) { + result := PrometheusRuleGroupsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PrometheusRuleGroupResource); err != nil { + return PrometheusRuleGroupsClientGetResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - Retrieve Prometheus rule group definitions in a resource group. +// +// Generated from API version 2021-07-22-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - PrometheusRuleGroupsClientListByResourceGroupOptions contains the optional parameters for the PrometheusRuleGroupsClient.NewListByResourceGroupPager +// method. +func (client *PrometheusRuleGroupsClient) NewListByResourceGroupPager(resourceGroupName string, options *PrometheusRuleGroupsClientListByResourceGroupOptions) *runtime.Pager[PrometheusRuleGroupsClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[PrometheusRuleGroupsClientListByResourceGroupResponse]{ + More: func(page PrometheusRuleGroupsClientListByResourceGroupResponse) bool { + return false + }, + Fetcher: func(ctx context.Context, page *PrometheusRuleGroupsClientListByResourceGroupResponse) (PrometheusRuleGroupsClientListByResourceGroupResponse, error) { + req, err := client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + if err != nil { + return PrometheusRuleGroupsClientListByResourceGroupResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrometheusRuleGroupsClientListByResourceGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PrometheusRuleGroupsClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listByResourceGroupHandleResponse(resp) + }, + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *PrometheusRuleGroupsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *PrometheusRuleGroupsClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/prometheusRuleGroups" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-07-22-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *PrometheusRuleGroupsClient) listByResourceGroupHandleResponse(resp *http.Response) (PrometheusRuleGroupsClientListByResourceGroupResponse, error) { + result := PrometheusRuleGroupsClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PrometheusRuleGroupResourceCollection); err != nil { + return PrometheusRuleGroupsClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - Retrieve Prometheus rule group definitions in a subscription. +// +// Generated from API version 2021-07-22-preview +// - options - PrometheusRuleGroupsClientListBySubscriptionOptions contains the optional parameters for the PrometheusRuleGroupsClient.NewListBySubscriptionPager +// method. +func (client *PrometheusRuleGroupsClient) NewListBySubscriptionPager(options *PrometheusRuleGroupsClientListBySubscriptionOptions) *runtime.Pager[PrometheusRuleGroupsClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[PrometheusRuleGroupsClientListBySubscriptionResponse]{ + More: func(page PrometheusRuleGroupsClientListBySubscriptionResponse) bool { + return false + }, + Fetcher: func(ctx context.Context, page *PrometheusRuleGroupsClientListBySubscriptionResponse) (PrometheusRuleGroupsClientListBySubscriptionResponse, error) { + req, err := client.listBySubscriptionCreateRequest(ctx, options) + if err != nil { + return PrometheusRuleGroupsClientListBySubscriptionResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrometheusRuleGroupsClientListBySubscriptionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PrometheusRuleGroupsClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) + } + return client.listBySubscriptionHandleResponse(resp) + }, + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *PrometheusRuleGroupsClient) listBySubscriptionCreateRequest(ctx context.Context, options *PrometheusRuleGroupsClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/prometheusRuleGroups" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-07-22-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *PrometheusRuleGroupsClient) listBySubscriptionHandleResponse(resp *http.Response) (PrometheusRuleGroupsClientListBySubscriptionResponse, error) { + result := PrometheusRuleGroupsClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PrometheusRuleGroupResourceCollection); err != nil { + return PrometheusRuleGroupsClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// Update - Update an Prometheus rule group definition. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-07-22-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - ruleGroupName - The name of the rule group. +// - parameters - The parameters of the rule group to update. +// - options - PrometheusRuleGroupsClientUpdateOptions contains the optional parameters for the PrometheusRuleGroupsClient.Update +// method. +func (client *PrometheusRuleGroupsClient) Update(ctx context.Context, resourceGroupName string, ruleGroupName string, parameters PrometheusRuleGroupResourcePatch, options *PrometheusRuleGroupsClientUpdateOptions) (PrometheusRuleGroupsClientUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, ruleGroupName, parameters, options) + if err != nil { + return PrometheusRuleGroupsClientUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrometheusRuleGroupsClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PrometheusRuleGroupsClientUpdateResponse{}, runtime.NewResponseError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *PrometheusRuleGroupsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, ruleGroupName string, parameters PrometheusRuleGroupResourcePatch, options *PrometheusRuleGroupsClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/prometheusRuleGroups/{ruleGroupName}" + 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 ruleGroupName == "" { + return nil, errors.New("parameter ruleGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{ruleGroupName}", url.PathEscape(ruleGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-07-22-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, parameters) +} + +// updateHandleResponse handles the Update response. +func (client *PrometheusRuleGroupsClient) updateHandleResponse(resp *http.Response) (PrometheusRuleGroupsClientUpdateResponse, error) { + result := PrometheusRuleGroupsClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PrometheusRuleGroupResource); err != nil { + return PrometheusRuleGroupsClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/response_types.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/response_types.go index 3cc309bc8657..617be2caa061 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/response_types.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/response_types.go @@ -29,14 +29,14 @@ type AlertProcessingRulesClientGetByNameResponse struct { XMSRequestID *string } -// AlertProcessingRulesClientListByResourceGroupResponse contains the response from method AlertProcessingRulesClient.ListByResourceGroup. +// AlertProcessingRulesClientListByResourceGroupResponse contains the response from method AlertProcessingRulesClient.NewListByResourceGroupPager. type AlertProcessingRulesClientListByResourceGroupResponse struct { AlertProcessingRulesList // XMSRequestID contains the information returned from the x-ms-request-id header response. XMSRequestID *string } -// AlertProcessingRulesClientListBySubscriptionResponse contains the response from method AlertProcessingRulesClient.ListBySubscription. +// AlertProcessingRulesClientListBySubscriptionResponse contains the response from method AlertProcessingRulesClient.NewListBySubscriptionPager. type AlertProcessingRulesClientListBySubscriptionResponse struct { AlertProcessingRulesList // XMSRequestID contains the information returned from the x-ms-request-id header response. @@ -50,12 +50,22 @@ type AlertProcessingRulesClientUpdateResponse struct { XMSRequestID *string } +// AlertRuleRecommendationsClientListByResourceResponse contains the response from method AlertRuleRecommendationsClient.NewListByResourcePager. +type AlertRuleRecommendationsClientListByResourceResponse struct { + AlertRuleRecommendationsListResponse +} + +// AlertRuleRecommendationsClientListByTargetTypeResponse contains the response from method AlertRuleRecommendationsClient.NewListByTargetTypePager. +type AlertRuleRecommendationsClientListByTargetTypeResponse struct { + AlertRuleRecommendationsListResponse +} + // AlertsClientChangeStateResponse contains the response from method AlertsClient.ChangeState. type AlertsClientChangeStateResponse struct { Alert } -// AlertsClientGetAllResponse contains the response from method AlertsClient.GetAll. +// AlertsClientGetAllResponse contains the response from method AlertsClient.NewGetAllPager. type AlertsClientGetAllResponse struct { AlertsList } @@ -80,11 +90,41 @@ type AlertsClientMetaDataResponse struct { AlertsMetaData } -// OperationsClientListResponse contains the response from method OperationsClient.List. +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { OperationsList } +// PrometheusRuleGroupsClientCreateOrUpdateResponse contains the response from method PrometheusRuleGroupsClient.CreateOrUpdate. +type PrometheusRuleGroupsClientCreateOrUpdateResponse struct { + PrometheusRuleGroupResource +} + +// PrometheusRuleGroupsClientDeleteResponse contains the response from method PrometheusRuleGroupsClient.Delete. +type PrometheusRuleGroupsClientDeleteResponse struct { + // placeholder for future response values +} + +// PrometheusRuleGroupsClientGetResponse contains the response from method PrometheusRuleGroupsClient.Get. +type PrometheusRuleGroupsClientGetResponse struct { + PrometheusRuleGroupResource +} + +// PrometheusRuleGroupsClientListByResourceGroupResponse contains the response from method PrometheusRuleGroupsClient.NewListByResourceGroupPager. +type PrometheusRuleGroupsClientListByResourceGroupResponse struct { + PrometheusRuleGroupResourceCollection +} + +// PrometheusRuleGroupsClientListBySubscriptionResponse contains the response from method PrometheusRuleGroupsClient.NewListBySubscriptionPager. +type PrometheusRuleGroupsClientListBySubscriptionResponse struct { + PrometheusRuleGroupResourceCollection +} + +// PrometheusRuleGroupsClientUpdateResponse contains the response from method PrometheusRuleGroupsClient.Update. +type PrometheusRuleGroupsClientUpdateResponse struct { + PrometheusRuleGroupResource +} + // SmartGroupsClientChangeStateResponse contains the response from method SmartGroupsClient.ChangeState. type SmartGroupsClientChangeStateResponse struct { SmartGroup @@ -92,7 +132,7 @@ type SmartGroupsClientChangeStateResponse struct { XMSRequestID *string } -// SmartGroupsClientGetAllResponse contains the response from method SmartGroupsClient.GetAll. +// SmartGroupsClientGetAllResponse contains the response from method SmartGroupsClient.NewGetAllPager. type SmartGroupsClientGetAllResponse struct { SmartGroupsList } diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/smartgroups_client.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/smartgroups_client.go index 510a64807376..cf8215ac2993 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/smartgroups_client.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/smartgroups_client.go @@ -33,9 +33,9 @@ type SmartGroupsClient struct { } // NewSmartGroupsClient creates a new instance of SmartGroupsClient 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. +// - 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 NewSmartGroupsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SmartGroupsClient, error) { if options == nil { options = &arm.ClientOptions{} @@ -58,10 +58,11 @@ func NewSmartGroupsClient(subscriptionID string, credential azcore.TokenCredenti // ChangeState - Change the state of a Smart Group. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-05-05-preview -// smartGroupID - Smart group unique id. -// newState - New state of the alert. -// options - SmartGroupsClientChangeStateOptions contains the optional parameters for the SmartGroupsClient.ChangeState method. +// - smartGroupID - Smart group unique id. +// - newState - New state of the alert. +// - options - SmartGroupsClientChangeStateOptions contains the optional parameters for the SmartGroupsClient.ChangeState method. func (client *SmartGroupsClient) ChangeState(ctx context.Context, smartGroupID string, newState AlertState, options *SmartGroupsClientChangeStateOptions) (SmartGroupsClientChangeStateResponse, error) { req, err := client.changeStateCreateRequest(ctx, smartGroupID, newState, options) if err != nil { @@ -113,9 +114,9 @@ func (client *SmartGroupsClient) changeStateHandleResponse(resp *http.Response) } // NewGetAllPager - List all the Smart Groups within a specified subscription. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-05-05-preview -// options - SmartGroupsClientGetAllOptions contains the optional parameters for the SmartGroupsClient.GetAll method. +// - options - SmartGroupsClientGetAllOptions contains the optional parameters for the SmartGroupsClient.NewGetAllPager method. func (client *SmartGroupsClient) NewGetAllPager(options *SmartGroupsClientGetAllOptions) *runtime.Pager[SmartGroupsClientGetAllResponse] { return runtime.NewPager(runtime.PagingHandler[SmartGroupsClientGetAllResponse]{ More: func(page SmartGroupsClientGetAllResponse) bool { @@ -206,9 +207,10 @@ func (client *SmartGroupsClient) getAllHandleResponse(resp *http.Response) (Smar // GetByID - Get information related to a specific Smart Group. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-05-05-preview -// smartGroupID - Smart group unique id. -// options - SmartGroupsClientGetByIDOptions contains the optional parameters for the SmartGroupsClient.GetByID method. +// - smartGroupID - Smart group unique id. +// - options - SmartGroupsClientGetByIDOptions contains the optional parameters for the SmartGroupsClient.GetByID method. func (client *SmartGroupsClient) GetByID(ctx context.Context, smartGroupID string, options *SmartGroupsClientGetByIDOptions) (SmartGroupsClientGetByIDResponse, error) { req, err := client.getByIDCreateRequest(ctx, smartGroupID, options) if err != nil { @@ -260,9 +262,10 @@ func (client *SmartGroupsClient) getByIDHandleResponse(resp *http.Response) (Sma // GetHistory - Get the history a smart group, which captures any Smart Group state changes (New/Acknowledged/Closed) . // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-05-05-preview -// smartGroupID - Smart group unique id. -// options - SmartGroupsClientGetHistoryOptions contains the optional parameters for the SmartGroupsClient.GetHistory method. +// - smartGroupID - Smart group unique id. +// - options - SmartGroupsClientGetHistoryOptions contains the optional parameters for the SmartGroupsClient.GetHistory method. func (client *SmartGroupsClient) GetHistory(ctx context.Context, smartGroupID string, options *SmartGroupsClientGetHistoryOptions) (SmartGroupsClientGetHistoryResponse, error) { req, err := client.getHistoryCreateRequest(ctx, smartGroupID, options) if err != nil { diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/smartgroups_client_example_test.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/smartgroups_client_example_test.go deleted file mode 100644 index f903fc236301..000000000000 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/smartgroups_client_example_test.go +++ /dev/null @@ -1,109 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armalertsmanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/alertsmanagement/armalertsmanagement" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2019-05-05-preview/examples/SmartGroups_List.json -func ExampleSmartGroupsClient_NewGetAllPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armalertsmanagement.NewSmartGroupsClient("dd91de05-d791-4ceb-b6dc-988682dc7d72", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewGetAllPager(&armalertsmanagement.SmartGroupsClientGetAllOptions{TargetResource: nil, - TargetResourceGroup: nil, - TargetResourceType: nil, - MonitorService: nil, - MonitorCondition: nil, - Severity: nil, - SmartGroupState: nil, - TimeRange: nil, - PageCount: nil, - SortBy: nil, - SortOrder: nil, - }) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2019-05-05-preview/examples/SmartGroups_GetById.json -func ExampleSmartGroupsClient_GetByID() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armalertsmanagement.NewSmartGroupsClient("9e261de7-c804-4b9d-9ebf-6f50fe350a9a", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetByID(ctx, "603675da-9851-4b26-854a-49fc53d32715", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2019-05-05-preview/examples/SmartGroups_ChangeState.json -func ExampleSmartGroupsClient_ChangeState() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armalertsmanagement.NewSmartGroupsClient("dd91de05-d791-4ceb-b6dc-988682dc7d72", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.ChangeState(ctx, "a808445e-bb38-4751-85c2-1b109ccc1059", armalertsmanagement.AlertStateAcknowledged, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2019-05-05-preview/examples/SmartGroups_History.json -func ExampleSmartGroupsClient_GetHistory() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armalertsmanagement.NewSmartGroupsClient("9e261de7-c804-4b9d-9ebf-6f50fe350a9a", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetHistory(ctx, "a808445e-bb38-4751-85c2-1b109ccc1059", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/time_rfc3339.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/time_rfc3339.go index 48b404cfd6d9..de9bd61bf4b9 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/time_rfc3339.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/time_rfc3339.go @@ -62,7 +62,7 @@ func (t *timeRFC3339) Parse(layout, value string) error { return err } -func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { +func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) {