diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/CHANGELOG.md b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/CHANGELOG.md index d66c9c975183..05ea88e82524 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/CHANGELOG.md +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/CHANGELOG.md @@ -1,5 +1,51 @@ # Release History +## 0.9.0 (2023-05-30) +### Breaking Changes + +- Function `NewClientFactory` parameter(s) have been changed from `(string, azcore.TokenCredential, *arm.ClientOptions)` to `(string, string, azcore.TokenCredential, *arm.ClientOptions)` +- Type of `AlertsClientChangeStateOptions.Comment` has been changed from `*string` to `*Comments` +- Type of `ErrorResponse.Error` has been changed from `*ErrorResponseBody` to `*ErrorDetail` +- Type of `ErrorResponseAutoGenerated.Error` has been changed from `*ErrorResponseBodyAutoGenerated` to `*ErrorResponseBody` +- Type of `ErrorResponseAutoGenerated2.Error` has been changed from `*ErrorResponseBodyAutoGenerated2` to `*ErrorResponseBodyAutoGenerated` + +### Features Added + +- New enum type `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 `*ClientFactory.NewAlertRuleRecommendationsClient() *AlertRuleRecommendationsClient` +- New function `*ClientFactory.NewPrometheusRuleGroupsClient() *PrometheusRuleGroupsClient` +- 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, PrometheusRuleGroupResourcePatchParameters, *PrometheusRuleGroupsClientUpdateOptions) (PrometheusRuleGroupsClientUpdateResponse, error)` +- New struct `AlertRuleRecommendationProperties` +- New struct `AlertRuleRecommendationResource` +- New struct `AlertRuleRecommendationsListResponse` +- New struct `Comments` +- New struct `ErrorAdditionalInfo` +- New struct `ErrorDetail` +- New struct `ErrorResponseAutoGenerated3` +- New struct `PrometheusRule` +- New struct `PrometheusRuleGroupAction` +- New struct `PrometheusRuleGroupProperties` +- New struct `PrometheusRuleGroupResource` +- New struct `PrometheusRuleGroupResourceCollection` +- New struct `PrometheusRuleGroupResourcePatchParameters` +- New struct `PrometheusRuleGroupResourcePatchParametersProperties` +- New struct `PrometheusRuleResolveConfiguration` +- New struct `ProxyResource` +- New struct `ResourceAutoGenerated` +- New struct `RuleArmTemplate` +- New struct `TrackedResource` +- New field `SystemData` in struct `Resource` + + ## 0.8.1 (2023-04-14) ### Bug Fixes 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 58f3cfbfe703..000000000000 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alertprocessingrules_client_example_test.go +++ /dev/null @@ -1,961 +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. -// DO NOT EDIT. - -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/blob/a436672b07fb1fe276c203b086b3f0e0d0c4aa24/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() - clientFactory, err := armalertsmanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAlertProcessingRulesClient().NewListBySubscriptionPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.AlertProcessingRulesList = armalertsmanagement.AlertProcessingRulesList{ - // Value: []*armalertsmanagement.AlertProcessingRule{ - // { - // Name: to.Ptr("DailySuppression"), - // Type: to.Ptr("Microsoft.AlertsManagement/actionRules"), - // ID: to.Ptr("/subscriptions/1e3ff1c0-771a-4119-a03b-be82a51e232d/resourceGroups/alertscorrelationrg/providers/Microsoft.AlertsManagement/actionRules/DailySuppression"), - // Location: to.Ptr("Global"), - // Tags: map[string]*string{ - // }, - // Properties: &armalertsmanagement.AlertProcessingRuleProperties{ - // Description: to.Ptr("Alert processing rule on resource group for daily suppression"), - // Actions: []armalertsmanagement.ActionClassification{ - // &armalertsmanagement.RemoveAllActionGroups{ - // ActionType: to.Ptr(armalertsmanagement.ActionTypeRemoveAllActionGroups), - // }}, - // Conditions: []*armalertsmanagement.Condition{ - // { - // Field: to.Ptr(armalertsmanagement.FieldSeverity), - // Operator: to.Ptr(armalertsmanagement.OperatorEquals), - // Values: []*string{ - // to.Ptr("Sev0"), - // to.Ptr("Sev2")}, - // }, - // { - // Field: to.Ptr(armalertsmanagement.FieldMonitorService), - // Operator: to.Ptr(armalertsmanagement.OperatorEquals), - // Values: []*string{ - // to.Ptr("Platform"), - // to.Ptr("Application Insights")}, - // }, - // { - // Field: to.Ptr(armalertsmanagement.FieldTargetResourceType), - // Operator: to.Ptr(armalertsmanagement.OperatorNotEquals), - // Values: []*string{ - // to.Ptr("Microsoft.Compute/VirtualMachines")}, - // }}, - // Enabled: to.Ptr(true), - // Schedule: &armalertsmanagement.Schedule{ - // EffectiveFrom: to.Ptr("2018-01-10T22:05:09"), - // EffectiveUntil: to.Ptr("2018-12-10T22:05:09"), - // Recurrences: []armalertsmanagement.RecurrenceClassification{ - // &armalertsmanagement.DailyRecurrence{ - // EndTime: to.Ptr("14:00:00"), - // RecurrenceType: to.Ptr(armalertsmanagement.RecurrenceTypeDaily), - // StartTime: to.Ptr("06:00:00"), - // }}, - // TimeZone: to.Ptr("Pacific Standard Time"), - // }, - // Scopes: []*string{ - // to.Ptr("/subscriptions/1e3ff1c0-771a-4119-a03b-be82a51e232d/resourceGroups/alertscorrelationrg")}, - // }, - // SystemData: &armalertsmanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-12T22:05:09Z"); return t}()), - // CreatedBy: to.Ptr("abc@microsoft.com"), - // CreatedByType: to.Ptr(armalertsmanagement.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-12T22:05:09Z"); return t}()), - // LastModifiedBy: to.Ptr("xyz@microsoft.com"), - // LastModifiedByType: to.Ptr(armalertsmanagement.CreatedByTypeUser), - // }, - // }, - // { - // Name: to.Ptr("WeeklySuppression"), - // Type: to.Ptr("Microsoft.AlertsManagement/actionRules"), - // ID: to.Ptr("/subscriptions/1e3ff1c0-771a-4119-a03b-be82a51e232d/resourceGroups/alertscorrelationrg/providers/Microsoft.AlertsManagement/actionRules/WeeklySuppression"), - // Location: to.Ptr("Global"), - // Tags: map[string]*string{ - // }, - // Properties: &armalertsmanagement.AlertProcessingRuleProperties{ - // Description: to.Ptr("Alert processing rule on resource group for adding action group"), - // Actions: []armalertsmanagement.ActionClassification{ - // &armalertsmanagement.AddActionGroups{ - // ActionType: to.Ptr(armalertsmanagement.ActionTypeAddActionGroups), - // ActionGroupIDs: []*string{ - // to.Ptr("actiongGroup1")}, - // }}, - // Conditions: []*armalertsmanagement.Condition{ - // { - // Field: to.Ptr(armalertsmanagement.FieldMonitorCondition), - // Operator: to.Ptr(armalertsmanagement.OperatorEquals), - // Values: []*string{ - // to.Ptr("Fired")}, - // }, - // { - // Field: to.Ptr(armalertsmanagement.FieldDescription), - // Operator: to.Ptr(armalertsmanagement.OperatorContains), - // Values: []*string{ - // to.Ptr("Percentage CPU greater than 80%"), - // to.Ptr("Metric alert on resource foo")}, - // }}, - // Enabled: to.Ptr(true), - // Scopes: []*string{ - // to.Ptr("/subscriptions/1e3ff1c0-771a-4119-a03b-be82a51e232d/resourceGroups/alertscorrelationrg/providers/Microsoft.Compute/VirtualMachines/testResource")}, - // }, - // SystemData: &armalertsmanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-12T22:05:09Z"); return t}()), - // CreatedBy: to.Ptr("abc@microsoft.com"), - // CreatedByType: to.Ptr(armalertsmanagement.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-12T22:05:09Z"); return t}()), - // LastModifiedBy: to.Ptr("xyz@microsoft.com"), - // LastModifiedByType: to.Ptr(armalertsmanagement.CreatedByTypeUser), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a436672b07fb1fe276c203b086b3f0e0d0c4aa24/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() - clientFactory, err := armalertsmanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAlertProcessingRulesClient().NewListByResourceGroupPager("alertscorrelationrg", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.AlertProcessingRulesList = armalertsmanagement.AlertProcessingRulesList{ - // Value: []*armalertsmanagement.AlertProcessingRule{ - // { - // Name: to.Ptr("DailySuppression"), - // Type: to.Ptr("Microsoft.AlertsManagement/actionRules"), - // ID: to.Ptr("/subscriptions/1e3ff1c0-771a-4119-a03b-be82a51e232d/resourceGroups/alertscorrelationrg/providers/Microsoft.AlertsManagement/actionRules/DailySuppression"), - // Location: to.Ptr("Global"), - // Tags: map[string]*string{ - // }, - // Properties: &armalertsmanagement.AlertProcessingRuleProperties{ - // Description: to.Ptr("Alert processing rule on resource group for daily suppression"), - // Actions: []armalertsmanagement.ActionClassification{ - // &armalertsmanagement.RemoveAllActionGroups{ - // ActionType: to.Ptr(armalertsmanagement.ActionTypeRemoveAllActionGroups), - // }}, - // Conditions: []*armalertsmanagement.Condition{ - // { - // Field: to.Ptr(armalertsmanagement.FieldSeverity), - // Operator: to.Ptr(armalertsmanagement.OperatorEquals), - // Values: []*string{ - // to.Ptr("Sev0"), - // to.Ptr("Sev2")}, - // }, - // { - // Field: to.Ptr(armalertsmanagement.FieldMonitorService), - // Operator: to.Ptr(armalertsmanagement.OperatorEquals), - // Values: []*string{ - // to.Ptr("Platform"), - // to.Ptr("Application Insights")}, - // }, - // { - // Field: to.Ptr(armalertsmanagement.FieldTargetResourceType), - // Operator: to.Ptr(armalertsmanagement.OperatorNotEquals), - // Values: []*string{ - // to.Ptr("Microsoft.Compute/VirtualMachines")}, - // }}, - // Enabled: to.Ptr(true), - // Schedule: &armalertsmanagement.Schedule{ - // EffectiveFrom: to.Ptr("2018-09-12T06:00:00"), - // EffectiveUntil: to.Ptr("2018-09-20T14:00:00"), - // Recurrences: []armalertsmanagement.RecurrenceClassification{ - // &armalertsmanagement.DailyRecurrence{ - // EndTime: to.Ptr("14:00:00"), - // RecurrenceType: to.Ptr(armalertsmanagement.RecurrenceTypeDaily), - // StartTime: to.Ptr("06:00:00"), - // }}, - // TimeZone: to.Ptr("Pacific Standard Time"), - // }, - // Scopes: []*string{ - // to.Ptr("/subscriptions/1e3ff1c0-771a-4119-a03b-be82a51e232d/resourceGroups/alertscorrelationrg")}, - // }, - // SystemData: &armalertsmanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-12T22:05:09Z"); return t}()), - // CreatedBy: to.Ptr("abc@microsoft.com"), - // CreatedByType: to.Ptr(armalertsmanagement.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-12T22:05:09Z"); return t}()), - // LastModifiedBy: to.Ptr("xyz@microsoft.com"), - // LastModifiedByType: to.Ptr(armalertsmanagement.CreatedByTypeUser), - // }, - // }, - // { - // Name: to.Ptr("WeeklySuppression"), - // Type: to.Ptr("Microsoft.AlertsManagement/actionRules"), - // ID: to.Ptr("/subscriptions/1e3ff1c0-771a-4119-a03b-be82a51e232d/resourceGroups/alertscorrelationrg/providers/Microsoft.AlertsManagement/actionRules/WeeklySuppression"), - // Location: to.Ptr("Global"), - // Tags: map[string]*string{ - // }, - // Properties: &armalertsmanagement.AlertProcessingRuleProperties{ - // Description: to.Ptr("Alert processing rule on resource group for sending email"), - // Actions: []armalertsmanagement.ActionClassification{ - // &armalertsmanagement.AddActionGroups{ - // ActionType: to.Ptr(armalertsmanagement.ActionTypeAddActionGroups), - // ActionGroupIDs: []*string{ - // to.Ptr("/subscriptions/1e3ff1c0-771a-4119-a03b-be82a51e232d/resourceGroups/alertscorrelationrg/providers/Microsoft.insights/actiongroups/testAG")}, - // }}, - // Conditions: []*armalertsmanagement.Condition{ - // { - // Field: to.Ptr(armalertsmanagement.FieldMonitorCondition), - // Operator: to.Ptr(armalertsmanagement.OperatorEquals), - // Values: []*string{ - // to.Ptr("Fired")}, - // }, - // { - // Field: to.Ptr(armalertsmanagement.FieldDescription), - // Operator: to.Ptr(armalertsmanagement.OperatorContains), - // Values: []*string{ - // to.Ptr("Percentage CPU greater than 80%"), - // to.Ptr("Metric alert on resource foo")}, - // }, - // { - // Field: to.Ptr(armalertsmanagement.FieldAlertContext), - // Operator: to.Ptr(armalertsmanagement.OperatorDoesNotContain), - // Values: []*string{ - // to.Ptr("testresource"), - // to.Ptr("foo")}, - // }}, - // Enabled: to.Ptr(true), - // Scopes: []*string{ - // to.Ptr("/subscriptions/1e3ff1c0-771a-4119-a03b-be82a51e232d/resourceGroups/alertscorrelationrg/providers/Microsoft.Compute/VirtualMachines/testResource")}, - // }, - // SystemData: &armalertsmanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-12T22:05:09Z"); return t}()), - // CreatedBy: to.Ptr("abc@microsoft.com"), - // CreatedByType: to.Ptr(armalertsmanagement.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-12T22:05:09Z"); return t}()), - // LastModifiedBy: to.Ptr("xyz@microsoft.com"), - // LastModifiedByType: to.Ptr(armalertsmanagement.CreatedByTypeUser), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a436672b07fb1fe276c203b086b3f0e0d0c4aa24/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() - clientFactory, err := armalertsmanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAlertProcessingRulesClient().GetByName(ctx, "alertscorrelationrg", "DailySuppression", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.AlertProcessingRule = armalertsmanagement.AlertProcessingRule{ - // Name: to.Ptr("DailySuppression"), - // Type: to.Ptr("Microsoft.AlertsManagement/actionRules"), - // ID: to.Ptr("/subscriptions/1e3ff1c0-771a-4119-a03b-be82a51e232d/resourceGroups/alertscorrelationrg/providers/Microsoft.AlertsManagement/actionRules/DailySuppression"), - // Location: to.Ptr("Global"), - // Tags: map[string]*string{ - // }, - // Properties: &armalertsmanagement.AlertProcessingRuleProperties{ - // Description: to.Ptr("Alert processing rule on resource group for daily and weekly scheduling"), - // Actions: []armalertsmanagement.ActionClassification{ - // &armalertsmanagement.AddActionGroups{ - // ActionType: to.Ptr(armalertsmanagement.ActionTypeAddActionGroups), - // ActionGroupIDs: []*string{ - // to.Ptr("actiongGroup1"), - // to.Ptr("actiongGroup2")}, - // }}, - // Conditions: []*armalertsmanagement.Condition{ - // { - // Field: to.Ptr(armalertsmanagement.FieldSeverity), - // Operator: to.Ptr(armalertsmanagement.OperatorEquals), - // Values: []*string{ - // to.Ptr("Sev0"), - // to.Ptr("Sev2")}, - // }, - // { - // Field: to.Ptr(armalertsmanagement.FieldMonitorService), - // Operator: to.Ptr(armalertsmanagement.OperatorEquals), - // Values: []*string{ - // to.Ptr("Platform"), - // to.Ptr("Application Insights")}, - // }, - // { - // Field: to.Ptr(armalertsmanagement.FieldMonitorCondition), - // Operator: to.Ptr(armalertsmanagement.OperatorEquals), - // Values: []*string{ - // to.Ptr("Fired")}, - // }, - // { - // Field: to.Ptr(armalertsmanagement.FieldTargetResourceType), - // Operator: to.Ptr(armalertsmanagement.OperatorNotEquals), - // Values: []*string{ - // to.Ptr("Microsoft.Compute/VirtualMachines")}, - // }}, - // Enabled: to.Ptr(true), - // Schedule: &armalertsmanagement.Schedule{ - // EffectiveFrom: to.Ptr("2018-01-10T22:05:09"), - // EffectiveUntil: to.Ptr("2018-12-10T22:05:09"), - // Recurrences: []armalertsmanagement.RecurrenceClassification{ - // &armalertsmanagement.DailyRecurrence{ - // EndTime: to.Ptr("14:00:00"), - // RecurrenceType: to.Ptr(armalertsmanagement.RecurrenceTypeDaily), - // StartTime: to.Ptr("06:00:00"), - // }, - // &armalertsmanagement.WeeklyRecurrence{ - // EndTime: to.Ptr("20:00:00"), - // RecurrenceType: to.Ptr(armalertsmanagement.RecurrenceTypeWeekly), - // StartTime: to.Ptr("10:00:00"), - // DaysOfWeek: []*armalertsmanagement.DaysOfWeek{ - // to.Ptr(armalertsmanagement.DaysOfWeekSaturday), - // to.Ptr(armalertsmanagement.DaysOfWeekSunday)}, - // }}, - // TimeZone: to.Ptr("Pacific Standard Time"), - // }, - // Scopes: []*string{ - // to.Ptr("/subscriptions/1e3ff1c0-771a-4119-a03b-be82a51e232d/resourceGroups/alertscorrelationrg")}, - // }, - // SystemData: &armalertsmanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-12T22:05:09Z"); return t}()), - // CreatedBy: to.Ptr("abc@microsoft.com"), - // CreatedByType: to.Ptr(armalertsmanagement.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-12T22:05:09Z"); return t}()), - // LastModifiedBy: to.Ptr("xyz@microsoft.com"), - // LastModifiedByType: to.Ptr(armalertsmanagement.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a436672b07fb1fe276c203b086b3f0e0d0c4aa24/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() - clientFactory, err := armalertsmanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAlertProcessingRulesClient().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) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.AlertProcessingRule = armalertsmanagement.AlertProcessingRule{ - // Name: to.Ptr("AddActionGroupToSubscription"), - // Type: to.Ptr("Microsoft.AlertsManagement/actionRules"), - // ID: to.Ptr("/subscriptions/subId1/resourceGroups/alertscorrelationrg/providers/Microsoft.AlertsManagement/actionRules/AddActionGroupToSubscription"), - // 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")}, - // }, - // SystemData: &armalertsmanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-02-12T22:05:09Z"); return t}()), - // CreatedBy: to.Ptr("abc@microsoft.com"), - // CreatedByType: to.Ptr(armalertsmanagement.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-02-13T16:15:34Z"); return t}()), - // LastModifiedBy: to.Ptr("xyz@microsoft.com"), - // LastModifiedByType: to.Ptr(armalertsmanagement.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a436672b07fb1fe276c203b086b3f0e0d0c4aa24/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() - clientFactory, err := armalertsmanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAlertProcessingRulesClient().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) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.AlertProcessingRule = armalertsmanagement.AlertProcessingRule{ - // Name: to.Ptr("AddActionGroupsBySeverity"), - // Type: to.Ptr("Microsoft.AlertsManagement/actionRules"), - // ID: to.Ptr("/subscriptions/subId1/resourceGroups/alertscorrelationrg/providers/Microsoft.AlertsManagement/actionRules/AddActionGroupsBySeverity"), - // 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")}, - // }, - // SystemData: &armalertsmanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-12T22:05:09Z"); return t}()), - // CreatedBy: to.Ptr("abc@microsoft.com"), - // CreatedByType: to.Ptr(armalertsmanagement.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-13T22:05:09Z"); return t}()), - // LastModifiedBy: to.Ptr("xyz@microsoft.com"), - // LastModifiedByType: to.Ptr(armalertsmanagement.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a436672b07fb1fe276c203b086b3f0e0d0c4aa24/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() - clientFactory, err := armalertsmanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAlertProcessingRulesClient().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) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.AlertProcessingRule = armalertsmanagement.AlertProcessingRule{ - // Name: to.Ptr("RemoveActionGroupsMaintenanceWindow"), - // Type: to.Ptr("Microsoft.AlertsManagement/actionRules"), - // ID: to.Ptr("/subscriptions/subId1/resourceGroups/alertscorrelationrg/providers/Microsoft.AlertsManagement/actionRules/RemoveActionGroupsMaintenanceWindow"), - // 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")}, - // }, - // SystemData: &armalertsmanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-12T20:13:29Z"); return t}()), - // CreatedBy: to.Ptr("abc@microsoft.com"), - // CreatedByType: to.Ptr(armalertsmanagement.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-12T22:05:09Z"); return t}()), - // LastModifiedBy: to.Ptr("xyz@microsoft.com"), - // LastModifiedByType: to.Ptr(armalertsmanagement.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a436672b07fb1fe276c203b086b3f0e0d0c4aa24/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() - clientFactory, err := armalertsmanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAlertProcessingRulesClient().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) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.AlertProcessingRule = armalertsmanagement.AlertProcessingRule{ - // Name: to.Ptr("RemoveActionGroupsSpecificAlertRule"), - // Type: to.Ptr("Microsoft.AlertsManagement/actionRules"), - // ID: to.Ptr("/subscriptions/subId1/resourceGroups/alertscorrelationrg/providers/Microsoft.AlertsManagement/actionRules/RemoveActionGroupsSpecificAlertRule"), - // 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")}, - // }, - // SystemData: &armalertsmanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-11T22:05:09Z"); return t}()), - // CreatedBy: to.Ptr("abc@microsoft.com"), - // CreatedByType: to.Ptr(armalertsmanagement.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-12T22:05:09Z"); return t}()), - // LastModifiedBy: to.Ptr("xyz@microsoft.com"), - // LastModifiedByType: to.Ptr(armalertsmanagement.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a436672b07fb1fe276c203b086b3f0e0d0c4aa24/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() - clientFactory, err := armalertsmanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAlertProcessingRulesClient().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) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.AlertProcessingRule = armalertsmanagement.AlertProcessingRule{ - // Name: to.Ptr("RemoveActionGroupsRecurringMaintenance"), - // Type: to.Ptr("Microsoft.AlertsManagement/actionRules"), - // ID: to.Ptr("/subscriptions/subId1/resourceGroups/alertscorrelationrg/providers/Microsoft.AlertsManagement/actionRules/RemoveActionGroupsRecurringMaintenance"), - // 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")}, - // }, - // SystemData: &armalertsmanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-11T22:05:09Z"); return t}()), - // CreatedBy: to.Ptr("abc@microsoft.com"), - // CreatedByType: to.Ptr(armalertsmanagement.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-12T22:05:09Z"); return t}()), - // LastModifiedBy: to.Ptr("xyz@microsoft.com"), - // LastModifiedByType: to.Ptr(armalertsmanagement.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a436672b07fb1fe276c203b086b3f0e0d0c4aa24/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() - clientFactory, err := armalertsmanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAlertProcessingRulesClient().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) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.AlertProcessingRule = armalertsmanagement.AlertProcessingRule{ - // Name: to.Ptr("RemoveActionGroupsOutsideBusinessHours"), - // Type: to.Ptr("Microsoft.AlertsManagement/actionRules"), - // ID: to.Ptr("/subscriptions/subId1/resourceGroups/alertscorrelationrg/providers/Microsoft.AlertsManagement/actionRules/RemoveActionGroupsOutsideBusinessHours"), - // 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")}, - // }, - // SystemData: &armalertsmanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-11T22:05:09Z"); return t}()), - // CreatedBy: to.Ptr("abc@microsoft.com"), - // CreatedByType: to.Ptr(armalertsmanagement.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-12T22:05:09Z"); return t}()), - // LastModifiedBy: to.Ptr("xyz@microsoft.com"), - // LastModifiedByType: to.Ptr(armalertsmanagement.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a436672b07fb1fe276c203b086b3f0e0d0c4aa24/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() - clientFactory, err := armalertsmanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAlertProcessingRulesClient().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/blob/a436672b07fb1fe276c203b086b3f0e0d0c4aa24/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() - clientFactory, err := armalertsmanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAlertProcessingRulesClient().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) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.AlertProcessingRule = armalertsmanagement.AlertProcessingRule{ - // Name: to.Ptr("WeeklySuppression"), - // Type: to.Ptr("Microsoft.AlertsManagement/actionRules"), - // ID: to.Ptr("/subscriptions/1e3ff1c0-771a-4119-a03b-be82a51e232d/resourceGroups/alertscorrelationrg/providers/Microsoft.AlertsManagement/actionRules/WeeklySuppression"), - // Location: to.Ptr("Global"), - // Tags: map[string]*string{ - // "key1": to.Ptr("value1"), - // "key2": to.Ptr("value2"), - // }, - // Properties: &armalertsmanagement.AlertProcessingRuleProperties{ - // Description: to.Ptr("Alert processing rule on resource group for weekly suppression"), - // Actions: []armalertsmanagement.ActionClassification{ - // &armalertsmanagement.RemoveAllActionGroups{ - // ActionType: to.Ptr(armalertsmanagement.ActionTypeRemoveAllActionGroups), - // }}, - // Conditions: []*armalertsmanagement.Condition{ - // { - // Field: to.Ptr(armalertsmanagement.FieldSeverity), - // Operator: to.Ptr(armalertsmanagement.OperatorEquals), - // Values: []*string{ - // to.Ptr("Sev0"), - // to.Ptr("Sev2")}, - // }, - // { - // Field: to.Ptr(armalertsmanagement.FieldMonitorService), - // Operator: to.Ptr(armalertsmanagement.OperatorEquals), - // Values: []*string{ - // to.Ptr("Platform"), - // to.Ptr("Application Insights")}, - // }, - // { - // Field: to.Ptr(armalertsmanagement.FieldTargetResourceType), - // Operator: to.Ptr(armalertsmanagement.OperatorNotEquals), - // Values: []*string{ - // to.Ptr("Microsoft.Compute/VirtualMachines")}, - // }}, - // Enabled: to.Ptr(false), - // Schedule: &armalertsmanagement.Schedule{ - // EffectiveFrom: to.Ptr("2018-12-10T22:05:09"), - // EffectiveUntil: to.Ptr("2018-12-05T22:05:09"), - // Recurrences: []armalertsmanagement.RecurrenceClassification{ - // &armalertsmanagement.WeeklyRecurrence{ - // EndTime: to.Ptr("14:00:00"), - // RecurrenceType: to.Ptr(armalertsmanagement.RecurrenceTypeWeekly), - // StartTime: to.Ptr("06:00:00"), - // DaysOfWeek: []*armalertsmanagement.DaysOfWeek{ - // to.Ptr(armalertsmanagement.DaysOfWeekTuesday), - // to.Ptr(armalertsmanagement.DaysOfWeekFriday)}, - // }}, - // TimeZone: to.Ptr("Pacific Standard Time"), - // }, - // Scopes: []*string{ - // to.Ptr("/subscriptions/1e3ff1c0-771a-4119-a03b-be82a51e232d/resourceGroups/alertscorrelationrg")}, - // }, - // SystemData: &armalertsmanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-12T22:05:09Z"); return t}()), - // CreatedBy: to.Ptr("abc@microsoft.com"), - // CreatedByType: to.Ptr(armalertsmanagement.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-12T22:05:09Z"); return t}()), - // LastModifiedBy: to.Ptr("xyz@microsoft.com"), - // LastModifiedByType: to.Ptr(armalertsmanagement.CreatedByTypeUser), - // }, - // } -} diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alertrulerecommendations_client.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alertrulerecommendations_client.go new file mode 100644 index 000000000000..1d36f903b7b9 --- /dev/null +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alertrulerecommendations_client.go @@ -0,0 +1,167 @@ +//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" + "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 { + internal *arm.Client + subscriptionID string + targetType string +} + +// 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) { + cl, err := arm.NewClient(moduleName+".AlertRuleRecommendationsClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &AlertRuleRecommendationsClient{ + subscriptionID: subscriptionID, + targetType: targetType, + internal: cl, + } + 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.internal.Pipeline().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.internal.Endpoint(), 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.internal.Pipeline().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.internal.Endpoint(), 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 477eb2b19591..c343dc61a8dc 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alerts_client.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alerts_client.go @@ -16,7 +16,6 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "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" @@ -89,8 +88,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 } 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 94294a393993..000000000000 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alerts_client_example_test.go +++ /dev/null @@ -1,516 +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. -// DO NOT EDIT. - -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/blob/a436672b07fb1fe276c203b086b3f0e0d0c4aa24/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() - clientFactory, err := armalertsmanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAlertsClient().MetaData(ctx, armalertsmanagement.IdentifierMonitorServiceList, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.AlertsMetaData = armalertsmanagement.AlertsMetaData{ - // Properties: &armalertsmanagement.MonitorServiceList{ - // MetadataIdentifier: to.Ptr(armalertsmanagement.MetadataIdentifierMonitorServiceList), - // Data: []*armalertsmanagement.MonitorServiceDetails{ - // { - // Name: to.Ptr("ActivityLog Administrative"), - // DisplayName: to.Ptr("Activity Log - Administrative"), - // }, - // { - // Name: to.Ptr("ActivityLog Autoscale"), - // DisplayName: to.Ptr("Activity Log - Autoscale"), - // }, - // { - // Name: to.Ptr("ActivityLog Policy"), - // DisplayName: to.Ptr("Activity Log - Policy"), - // }, - // { - // Name: to.Ptr("ActivityLog Recommendation"), - // DisplayName: to.Ptr("Activity Log - Recommendation"), - // }, - // { - // Name: to.Ptr("ActivityLog Security"), - // DisplayName: to.Ptr("Activity Log - Security"), - // }, - // { - // Name: to.Ptr("Application Insights"), - // DisplayName: to.Ptr("Application Insights"), - // }, - // { - // Name: to.Ptr("Azure Backup"), - // DisplayName: to.Ptr("Azure Backup"), - // }, - // { - // Name: to.Ptr("Custom"), - // DisplayName: to.Ptr("Custom"), - // }, - // { - // Name: to.Ptr("Data Box Edge"), - // DisplayName: to.Ptr("Data Box Edge"), - // }, - // { - // Name: to.Ptr("VM Insights"), - // DisplayName: to.Ptr("VM Insights"), - // }, - // { - // Name: to.Ptr("Log Analytics"), - // DisplayName: to.Ptr("Log Analytics"), - // }, - // { - // Name: to.Ptr("Nagios"), - // DisplayName: to.Ptr("NAGIOS"), - // }, - // { - // Name: to.Ptr("Platform"), - // DisplayName: to.Ptr("Platform"), - // }, - // { - // Name: to.Ptr("Resource Health"), - // DisplayName: to.Ptr("Resource Health"), - // }, - // { - // Name: to.Ptr("SCOM"), - // DisplayName: to.Ptr("SCOM"), - // }, - // { - // Name: to.Ptr("ServiceHealth"), - // DisplayName: to.Ptr("Service Health"), - // }, - // { - // Name: to.Ptr("Smart Detector"), - // DisplayName: to.Ptr("SmartDetector"), - // }, - // { - // Name: to.Ptr("Zabbix"), - // DisplayName: to.Ptr("ZABBIX"), - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a436672b07fb1fe276c203b086b3f0e0d0c4aa24/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() - clientFactory, err := armalertsmanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAlertsClient().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() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.AlertsList = armalertsmanagement.AlertsList{ - // Value: []*armalertsmanagement.Alert{ - // { - // Name: to.Ptr("cpu alert"), - // Type: to.Ptr("Microsoft.AlertsManagement/alerts"), - // ID: to.Ptr("/subscriptions/9e261de7-c804-4b9d-9ebf-6f50fe350a9a/providers/Microsoft.AlertsManagement/alerts/66114d64-d9d9-478b-95c9-b789d6502100"), - // Properties: &armalertsmanagement.AlertProperties{ - // Context: map[string]any{ - // }, - // EgressConfig: map[string]any{ - // }, - // Essentials: &armalertsmanagement.Essentials{ - // Description: to.Ptr("description of the alert"), - // ActionStatus: &armalertsmanagement.ActionStatus{ - // IsSuppressed: to.Ptr(false), - // }, - // AlertRule: to.Ptr("https://servisdffsdf.portal.mms.microsoft.com/#Workspace/overview/settings/details/Edit Alert Rule/details/index?savedSearchId=&scheduleId="), - // AlertState: to.Ptr(armalertsmanagement.AlertStateAcknowledged), - // LastModifiedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T15:51:02Z"); return t}()), - // LastModifiedUserName: to.Ptr("System"), - // MonitorCondition: to.Ptr(armalertsmanagement.MonitorConditionFired), - // MonitorConditionResolvedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T15:51:02Z"); return t}()), - // MonitorService: to.Ptr(armalertsmanagement.MonitorServiceApplicationInsights), - // Severity: to.Ptr(armalertsmanagement.SeveritySev3), - // SignalType: to.Ptr(armalertsmanagement.SignalTypeLog), - // SmartGroupID: to.Ptr("23d6b2ce-8c54-468f-aff0-sd32aebb7e56"), - // SmartGroupingReason: to.Ptr("Occurred frequently with other alerts"), - // SourceCreatedID: to.Ptr("6cd6b2ce-8c54-468f-aff0-9d12aebb7e49"), - // StartDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T15:51:02Z"); return t}()), - // TargetResource: to.Ptr("/subscriptions/3b540246-808d-4331-99aa-917b808a9166/resourcegroups/servicedeskresourcegroup/providers/microsoft.insights/components/servicedeskappinsight"), - // TargetResourceGroup: to.Ptr("servicedeskresourcegroup"), - // TargetResourceName: to.Ptr("servicedeskappinsight"), - // TargetResourceType: to.Ptr("components"), - // }, - // }, - // }, - // { - // Name: to.Ptr("cpu alert"), - // Type: to.Ptr("Microsoft.AlertsManagement/alerts"), - // ID: to.Ptr("/subscriptions/9e261de7-c804-4b9d-9ebf-6f50fe350a9a/providers/Microsoft.AlertsManagement/alerts/66114d64-d9d9-478b-95c9-b789d6502100"), - // Properties: &armalertsmanagement.AlertProperties{ - // Context: map[string]any{ - // }, - // EgressConfig: map[string]any{ - // }, - // Essentials: &armalertsmanagement.Essentials{ - // Description: to.Ptr("description of the alert"), - // ActionStatus: &armalertsmanagement.ActionStatus{ - // IsSuppressed: to.Ptr(false), - // }, - // AlertRule: to.Ptr("https://servicsdfsdf.portal.mms.microsoft.com/#Workspace/overview/settings/details/Edit Alert Rule/details/index?savedSearchId=&scheduleId="), - // AlertState: to.Ptr(armalertsmanagement.AlertStateNew), - // LastModifiedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T15:51:02Z"); return t}()), - // LastModifiedUserName: to.Ptr("System"), - // MonitorCondition: to.Ptr(armalertsmanagement.MonitorConditionFired), - // MonitorConditionResolvedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T15:51:02Z"); return t}()), - // MonitorService: to.Ptr(armalertsmanagement.MonitorServiceApplicationInsights), - // Severity: to.Ptr(armalertsmanagement.SeveritySev3), - // SignalType: to.Ptr(armalertsmanagement.SignalTypeLog), - // SmartGroupID: to.Ptr("d1c49c89-ea95-4697-a299-c0f5ebac62f1"), - // SmartGroupingReason: to.Ptr("Alerts that frequently occur together have been grouped."), - // SourceCreatedID: to.Ptr("6cd6b2ce-8c54-468f-aff0-9d12aebb7e49"), - // StartDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T15:51:02Z"); return t}()), - // TargetResource: to.Ptr("/subscriptions/3b540246-808d-4331-99aa-917b808a9166/resourcegroups/cind/providers/microsoft.operationalinsights/workspaces/servicedeskwcus"), - // TargetResourceGroup: to.Ptr("servicedeskresourcegroup"), - // TargetResourceName: to.Ptr("servicedeskwcus"), - // TargetResourceType: to.Ptr("components"), - // }, - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a436672b07fb1fe276c203b086b3f0e0d0c4aa24/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() - clientFactory, err := armalertsmanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAlertsClient().GetByID(ctx, "66114d64-d9d9-478b-95c9-b789d6502100", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Alert = armalertsmanagement.Alert{ - // Name: to.Ptr("cpu alert"), - // Type: to.Ptr("Microsoft.AlertsManagement/alerts"), - // ID: to.Ptr("/subscriptions/9e261de7-c804-4b9d-9ebf-6f50fe350a9a/providers/Microsoft.AlertsManagement/alerts/66114d64-d9d9-478b-95c9-b789d6502100"), - // Properties: &armalertsmanagement.AlertProperties{ - // Context: map[string]any{ - // }, - // EgressConfig: map[string]any{ - // }, - // Essentials: &armalertsmanagement.Essentials{ - // Description: to.Ptr("description of the alert"), - // ActionStatus: &armalertsmanagement.ActionStatus{ - // IsSuppressed: to.Ptr(false), - // }, - // AlertRule: to.Ptr("https://sersdfsdfinsight.portal.mms.microsoft.com/#Workspace/overview/settings/details/Edit Alert Rule/details/index?savedSearchId=&scheduleId="), - // AlertState: to.Ptr(armalertsmanagement.AlertStateAcknowledged), - // LastModifiedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T15:51:02Z"); return t}()), - // LastModifiedUserName: to.Ptr("System"), - // MonitorCondition: to.Ptr(armalertsmanagement.MonitorConditionFired), - // MonitorConditionResolvedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T15:51:02Z"); return t}()), - // MonitorService: to.Ptr(armalertsmanagement.MonitorServiceApplicationInsights), - // Severity: to.Ptr(armalertsmanagement.SeveritySev3), - // SignalType: to.Ptr(armalertsmanagement.SignalTypeLog), - // SmartGroupID: to.Ptr("23d6b2ce-8c54-468f-aff0-sd32aebb7e56"), - // SmartGroupingReason: to.Ptr("Occurred frequently with other alerts"), - // SourceCreatedID: to.Ptr("6cd6b2ce-8c54-468f-aff0-9d12aebb7e49"), - // StartDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T15:51:02Z"); return t}()), - // TargetResource: to.Ptr("/subscriptions/3b540246-808d-4331-99aa-917b808a9166/resourcegroups/servicedeskresourcegroup/providers/microsoft.insights/components/servicedeskappinsight"), - // TargetResourceGroup: to.Ptr("servicedeskresourcegroup"), - // TargetResourceName: to.Ptr("servicedeskappinsight"), - // TargetResourceType: to.Ptr("components"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a436672b07fb1fe276c203b086b3f0e0d0c4aa24/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() - clientFactory, err := armalertsmanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAlertsClient().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) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Alert = armalertsmanagement.Alert{ - // Name: to.Ptr("cpu alert"), - // Type: to.Ptr("Microsoft.AlertsManagement/alerts"), - // ID: to.Ptr("/subscriptions/9e261de7-c804-4b9d-9ebf-6f50fe350a9a/providers/Microsoft.AlertsManagement/alerts/66114d64-d9d9-478b-95c9-b789d6502100"), - // Properties: &armalertsmanagement.AlertProperties{ - // Context: map[string]any{ - // }, - // EgressConfig: map[string]any{ - // }, - // Essentials: &armalertsmanagement.Essentials{ - // Description: to.Ptr("description of the alert"), - // ActionStatus: &armalertsmanagement.ActionStatus{ - // IsSuppressed: to.Ptr(false), - // }, - // AlertRule: to.Ptr("https://servisdfsdfappinsight.portal.mms.microsoft.com/#Workspace/overview/settings/details/Edit Alert Rule/details/index?savedSearchId=&scheduleId="), - // AlertState: to.Ptr(armalertsmanagement.AlertStateAcknowledged), - // LastModifiedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T15:51:02Z"); return t}()), - // LastModifiedUserName: to.Ptr("System"), - // MonitorCondition: to.Ptr(armalertsmanagement.MonitorConditionFired), - // MonitorConditionResolvedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T15:51:02Z"); return t}()), - // MonitorService: to.Ptr(armalertsmanagement.MonitorServiceApplicationInsights), - // Severity: to.Ptr(armalertsmanagement.SeveritySev3), - // SignalType: to.Ptr(armalertsmanagement.SignalTypeLog), - // SmartGroupID: to.Ptr("23d6b2ce-8c54-468f-aff0-sd32aebb7e56"), - // SmartGroupingReason: to.Ptr("Occurred frequently with other alerts"), - // SourceCreatedID: to.Ptr("6cd6b2ce-8c54-468f-aff0-9d12aebb7e49"), - // StartDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-13T15:51:02Z"); return t}()), - // TargetResource: to.Ptr("/subscriptions/3b540246-808d-4331-99aa-917b808a9166/resourcegroups/servicedeskresourcegroup/providers/microsoft.insights/components/servicedeskappinsight"), - // TargetResourceGroup: to.Ptr("servicedeskresourcegroup"), - // TargetResourceName: to.Ptr("servicedeskappinsight"), - // TargetResourceType: to.Ptr("components"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a436672b07fb1fe276c203b086b3f0e0d0c4aa24/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() - clientFactory, err := armalertsmanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAlertsClient().GetHistory(ctx, "66114d64-d9d9-478b-95c9-b789d6502100", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.AlertModification = armalertsmanagement.AlertModification{ - // Name: to.Ptr("CPU Alert"), - // Type: to.Ptr("Microsoft.AlertsManagement/alerts"), - // ID: to.Ptr("/subscriptions/9e261de7-c804-4b9d-9ebf-6f50fe350a9a/providers/Microsoft.AlertsManagement/alerts/66114d64-d9d9-478b-95c9-b789d6502100/history/default"), - // Properties: &armalertsmanagement.AlertModificationProperties{ - // AlertID: to.Ptr("66114d64-d9d9-478b-95c9-b789d6502100"), - // Modifications: []*armalertsmanagement.AlertModificationItem{ - // { - // Description: to.Ptr("State changed from 'New' to 'Acknowledged'"), - // Comments: to.Ptr("Acknowledging alert"), - // ModificationEvent: to.Ptr(armalertsmanagement.AlertModificationEventStateChange), - // ModifiedAt: to.Ptr("2018-06-13T06:14:15.7378737Z"), - // ModifiedBy: to.Ptr("vikramm@microsoft.com"), - // NewValue: to.Ptr("Acknowledged"), - // OldValue: to.Ptr("New"), - // }, - // { - // Description: to.Ptr("New Alert Object is created"), - // Comments: to.Ptr(""), - // ModificationEvent: to.Ptr(armalertsmanagement.AlertModificationEventAlertCreated), - // ModifiedAt: to.Ptr("2018-06-13T06:09:01Z"), - // ModifiedBy: to.Ptr("System"), - // NewValue: to.Ptr(""), - // OldValue: to.Ptr(""), - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a436672b07fb1fe276c203b086b3f0e0d0c4aa24/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() - clientFactory, err := armalertsmanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAlertsClient().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) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.AlertsSummary = armalertsmanagement.AlertsSummary{ - // Name: to.Ptr("current"), - // Type: to.Ptr("Microsoft.AlertsManagement/alertsSummary"), - // ID: to.Ptr("/subscriptions/1e3ff1c0-771a-4119-a03b-be82a51e232d/providers/Microsoft.AlertsManagement/alertsSummary/current"), - // Properties: &armalertsmanagement.AlertsSummaryGroup{ - // Groupedby: to.Ptr("severity"), - // SmartGroupsCount: to.Ptr[int64](100), - // Total: to.Ptr[int64](14189), - // Values: []*armalertsmanagement.AlertsSummaryGroupItem{ - // { - // Name: to.Ptr("Sev0"), - // Count: to.Ptr[int64](6517), - // Groupedby: to.Ptr("alertState"), - // Values: []*armalertsmanagement.AlertsSummaryGroupItem{ - // { - // Name: to.Ptr("New"), - // Count: to.Ptr[int64](6517), - // }, - // { - // Name: to.Ptr("Acknowledged"), - // Count: to.Ptr[int64](0), - // }, - // { - // Name: to.Ptr("Closed"), - // Count: to.Ptr[int64](0), - // }}, - // }, - // { - // Name: to.Ptr("Sev1"), - // Count: to.Ptr[int64](3175), - // Groupedby: to.Ptr("alertState"), - // Values: []*armalertsmanagement.AlertsSummaryGroupItem{ - // { - // Name: to.Ptr("New"), - // Count: to.Ptr[int64](3175), - // }, - // { - // Name: to.Ptr("Acknowledged"), - // Count: to.Ptr[int64](0), - // }, - // { - // Name: to.Ptr("Closed"), - // Count: to.Ptr[int64](0), - // }}, - // }, - // { - // Name: to.Ptr("Sev2"), - // Count: to.Ptr[int64](1120), - // Groupedby: to.Ptr("alertState"), - // Values: []*armalertsmanagement.AlertsSummaryGroupItem{ - // { - // Name: to.Ptr("New"), - // Count: to.Ptr[int64](1120), - // }, - // { - // Name: to.Ptr("Acknowledged"), - // Count: to.Ptr[int64](0), - // }, - // { - // Name: to.Ptr("Closed"), - // Count: to.Ptr[int64](0), - // }}, - // }, - // { - // Name: to.Ptr("Sev3"), - // Count: to.Ptr[int64](1902), - // Groupedby: to.Ptr("alertState"), - // Values: []*armalertsmanagement.AlertsSummaryGroupItem{ - // { - // Name: to.Ptr("New"), - // Count: to.Ptr[int64](1902), - // }, - // { - // Name: to.Ptr("Acknowledged"), - // Count: to.Ptr[int64](0), - // }, - // { - // Name: to.Ptr("Closed"), - // Count: to.Ptr[int64](0), - // }}, - // }, - // { - // Name: to.Ptr("Sev4"), - // Count: to.Ptr[int64](1475), - // Groupedby: to.Ptr("alertState"), - // Values: []*armalertsmanagement.AlertsSummaryGroupItem{ - // { - // Name: to.Ptr("New"), - // Count: to.Ptr[int64](1475), - // }, - // { - // Name: to.Ptr("Acknowledged"), - // Count: to.Ptr[int64](0), - // }, - // { - // Name: to.Ptr("Closed"), - // Count: to.Ptr[int64](0), - // }}, - // }}, - // }, - // } -} diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/autorest.md b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/autorest.md index 39aff62bbd39..b2867bc02abd 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.8.1 +module-version: 0.9.0 modelerfour: lenient-model-deduplication: true ``` \ No newline at end of file diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/client_factory.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/client_factory.go index 1e0e6d4ca1e3..f9884a9b0d5c 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/client_factory.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/client_factory.go @@ -18,6 +18,7 @@ import ( // Don't use this type directly, use NewClientFactory instead. type ClientFactory struct { subscriptionID string + targetType string credential azcore.TokenCredential options *arm.ClientOptions } @@ -25,19 +26,25 @@ type ClientFactory struct { // NewClientFactory creates a new instance of ClientFactory with the specified values. // The parameter values will be propagated to any client created from this factory. // - 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 NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { +func NewClientFactory(subscriptionID string, targetType string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) if err != nil { return nil, err } return &ClientFactory{ - subscriptionID: subscriptionID, credential: credential, + subscriptionID: subscriptionID, targetType: targetType, credential: credential, options: options.Clone(), }, nil } +func (c *ClientFactory) NewPrometheusRuleGroupsClient() *PrometheusRuleGroupsClient { + subClient, _ := NewPrometheusRuleGroupsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + func (c *ClientFactory) NewAlertProcessingRulesClient() *AlertProcessingRulesClient { subClient, _ := NewAlertProcessingRulesClient(c.subscriptionID, c.credential, c.options) return subClient @@ -57,3 +64,8 @@ func (c *ClientFactory) NewSmartGroupsClient() *SmartGroupsClient { subClient, _ := NewSmartGroupsClient(c.subscriptionID, c.credential, c.options) return subClient } + +func (c *ClientFactory) NewAlertRuleRecommendationsClient() *AlertRuleRecommendationsClient { + subClient, _ := NewAlertRuleRecommendationsClient(c.subscriptionID, c.targetType, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/constants.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/constants.go index 3fee968e7ffd..125a5bf72929 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.8.1" + moduleVersion = "v0.9.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 a3fb08a259f8..3d752ca73000 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.4.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect - github.com/golang-jwt/jwt/v4 v4.5.0 // indirect - github.com/google/uuid v1.3.0 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect - golang.org/x/crypto v0.6.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect golang.org/x/net v0.7.0 // indirect - golang.org/x/sys v0.5.0 // indirect golang.org/x/text v0.7.0 // 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 8ba445a8c4da..b6bd7eaad1ba 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/go.sum +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/go.sum @@ -1,31 +1,15 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= -github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= 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/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= -github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/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/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= -github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= +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.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= -golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -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 6f6df9bd21cc..d4e3bba8e2b2 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/models.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/models.go @@ -215,10 +215,61 @@ type AlertProperties struct { EgressConfig any } +// AlertRuleRecommendationProperties - Describes the format of Alert Rule Recommendations response. +type AlertRuleRecommendationProperties struct { + // REQUIRED; The recommendation alert rule type. + AlertRuleType *string + + // REQUIRED; A dictionary that provides the display information for an alert rule recommendation. + DisplayInformation map[string]*string + + // REQUIRED; A complete ARM template to deploy the alert rules. + RuleArmTemplate *RuleArmTemplate +} + +// AlertRuleRecommendationResource - A single alert rule recommendation resource. +type AlertRuleRecommendationResource struct { + // REQUIRED; recommendation properties. + Properties *AlertRuleRecommendationProperties + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// 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 + + // URL to fetch the next set of recommendations. + NextLink *string +} + // 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.NewGetAllPager method. @@ -385,6 +436,11 @@ type AlertsSummaryGroupItem struct { Values []*AlertsSummaryGroupItem } +// Comments - Change alert state reason +type Comments struct { + Comments *string +} + // Condition to trigger an alert processing rule. type Condition struct { // Field for a given condition. @@ -418,20 +474,54 @@ func (d *DailyRecurrence) GetRecurrence() *Recurrence { } } -// ErrorResponse - An error response from the service. +// ErrorAdditionalInfo - The resource management error additional info. +type ErrorAdditionalInfo struct { + // READ-ONLY; The additional info. + Info any + + // READ-ONLY; The additional info type. + Type *string +} + +// ErrorDetail - The error detail. +type ErrorDetail struct { + // READ-ONLY; The error additional info. + AdditionalInfo []*ErrorAdditionalInfo + + // READ-ONLY; The error code. + Code *string + + // READ-ONLY; The error details. + Details []*ErrorDetail + + // READ-ONLY; The error message. + Message *string + + // READ-ONLY; The error target. + Target *string +} + +// ErrorResponse - Common error response for all Azure Resource Manager APIs to return error details for failed operations. +// (This also follows the OData error response format.). type ErrorResponse struct { - // Details of error response. - Error *ErrorResponseBody + // The error object. + Error *ErrorDetail } // ErrorResponseAutoGenerated - An error response from the service. type ErrorResponseAutoGenerated struct { // Details of error response. - Error *ErrorResponseBodyAutoGenerated + Error *ErrorResponseBody } // ErrorResponseAutoGenerated2 - An error response from the service. type ErrorResponseAutoGenerated2 struct { + // Details of error response. + Error *ErrorResponseBodyAutoGenerated +} + +// ErrorResponseAutoGenerated3 - An error response from the service. +type ErrorResponseAutoGenerated3 struct { // Details of error response. Error *ErrorResponseBodyAutoGenerated2 } @@ -669,6 +759,176 @@ type PatchProperties struct { Enabled *bool } +// PrometheusRule - An Azure Prometheus alerting or recording rule. +type PrometheusRule struct { + // REQUIRED; The PromQL expression to evaluate. https://prometheus.io/docs/prometheus/latest/querying/basics/. Evaluated periodically + // as given by 'interval', and the result recorded as a new set of time series + // with the metric name as given by 'record'. + Expression *string + + // Actions that are performed when the alert rule becomes active, and when an alert condition is resolved. + Actions []*PrometheusRuleGroupAction + + // Alert rule name. + Alert *string + + // The annotations clause specifies a set of informational labels that can be used to store longer additional information + // such as alert descriptions or runbook links. The annotation values can be + // templated. + Annotations map[string]*string + + // Enable/disable rule. + Enabled *bool + + // The amount of time alert must be active before firing. + For *string + + // Labels to add or overwrite before storing the result. + Labels map[string]*string + + // Recorded metrics name. + Record *string + + // Defines the configuration for resolving fired alerts. Only relevant for alerts. + ResolveConfiguration *PrometheusRuleResolveConfiguration + + // The severity of the alerts fired by the rule. Must be between 0 and 4. + Severity *int32 +} + +// PrometheusRuleGroupAction - An alert action. Only relevant for alerts. +type PrometheusRuleGroupAction struct { + // The resource id of the action group to use. + ActionGroupID *string + + // The properties of an action group object. + ActionProperties map[string]*string +} + +// PrometheusRuleGroupProperties - An Azure Prometheus rule group. +type PrometheusRuleGroupProperties struct { + // REQUIRED; Defines the rules in the Prometheus rule group. + Rules []*PrometheusRule + + // REQUIRED; Target Azure Monitor workspaces resource ids. This api-version is currently limited to creating with one scope. + // This may change in future. + Scopes []*string + + // Apply rule to data from a specific cluster. + ClusterName *string + + // Rule group description. + Description *string + + // Enable/disable rule group. + Enabled *bool + + // 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 +} + +// PrometheusRuleGroupResource - The Prometheus rule group resource. +type PrometheusRuleGroupResource struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // REQUIRED; The Prometheus rule group properties of the resource. + Properties *PrometheusRuleGroupProperties + + // Resource tags. + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// PrometheusRuleGroupResourceCollection - Represents a collection of alert rule resources. +type PrometheusRuleGroupResourceCollection struct { + // the values for the alert rule resources. + Value []*PrometheusRuleGroupResource +} + +// PrometheusRuleGroupResourcePatchParameters - The Prometheus rule group resource for patch operations. +type PrometheusRuleGroupResourcePatchParameters struct { + Properties *PrometheusRuleGroupResourcePatchParametersProperties + + // Resource tags + Tags map[string]*string +} + +type PrometheusRuleGroupResourcePatchParametersProperties struct { + // the flag that indicates whether the Prometheus rule group is enabled. + Enabled *bool +} + +// 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 { + // Enable alert auto-resolution. + AutoResolved *bool + + // Alert auto-resolution timeout. + TimeToResolve *string +} + +// 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 + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + // 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: @@ -706,8 +966,23 @@ func (r *RemoveAllActionGroups) GetAction() *Action { } } -// Resource - An azure resource object +// Resource - Common fields that are returned in the response for all Azure Resource Manager resources type Resource struct { + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// ResourceAutoGenerated - An azure resource object +type ResourceAutoGenerated struct { // READ-ONLY; Azure resource Id ID *string @@ -718,6 +993,24 @@ type Resource struct { Type *string } +// 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 + + // REQUIRED; Input parameter definitions + Parameters any + + // REQUIRED; Alert rule resource definitions + Resources []any + + // REQUIRED; JSON schema reference + Schema *string + + // REQUIRED; Variable definitions + Variables any +} + // 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. @@ -925,6 +1218,28 @@ type SystemData struct { LastModifiedByType *CreatedByType } +// 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 + + // Resource tags. + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + // 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 3832d5019b56..8849440bb70e 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/models_serde.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/models_serde.go @@ -425,6 +425,115 @@ 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]any) @@ -627,6 +736,33 @@ 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]any) @@ -697,6 +833,80 @@ func (d *DailyRecurrence) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type ErrorAdditionalInfo. +func (e ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateAny(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]any) @@ -778,6 +988,33 @@ 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]any) @@ -1301,98 +1538,527 @@ func (p *PatchProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type Recurrence. -func (r Recurrence) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type PrometheusRule. +func (p PrometheusRule) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "endTime", r.EndTime) - objectMap["recurrenceType"] = r.RecurrenceType - populate(objectMap, "startTime", r.StartTime) + 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) { +// MarshalJSON implements the json.Marshaller interface for type PrometheusRuleGroupAction. +func (p PrometheusRuleGroupAction) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - objectMap["actionType"] = ActionTypeRemoveAllActionGroups + populate(objectMap, "actionGroupId", p.ActionGroupID) + populate(objectMap, "actionProperties", p.ActionProperties) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type RemoveAllActionGroups. -func (r *RemoveAllActionGroups) UnmarshalJSON(data []byte) error { +// 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", r, err) + return fmt.Errorf("unmarshalling type %T: %v", p, err) } for key, val := range rawMsg { var err error switch key { - case "actionType": - err = unpopulate(val, "ActionType", &r.ActionType) + 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", r, err) + return fmt.Errorf("unmarshalling type %T: %v", p, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type Resource. -func (r Resource) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type PrometheusRuleGroupProperties. +func (p PrometheusRuleGroupProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", r.ID) - populate(objectMap, "name", r.Name) - populate(objectMap, "type", r.Type) + 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 Resource. -func (r *Resource) UnmarshalJSON(data []byte) error { +// 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", r, err) + 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", &r.ID) + case "clusterName": + err = unpopulate(val, "ClusterName", &p.ClusterName) delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &r.Name) + case "description": + err = unpopulate(val, "Description", &p.Description) delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &r.Type) + 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", r, err) + 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 PrometheusRuleGroupResourcePatchParameters. +func (p PrometheusRuleGroupResourcePatchParameters) 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 PrometheusRuleGroupResourcePatchParameters. +func (p *PrometheusRuleGroupResourcePatchParameters) 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 PrometheusRuleGroupResourcePatchParametersProperties. +func (p PrometheusRuleGroupResourcePatchParametersProperties) 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 PrometheusRuleGroupResourcePatchParametersProperties. +func (p *PrometheusRuleGroupResourcePatchParametersProperties) 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) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RemoveAllActionGroups. +func (r *RemoveAllActionGroups) 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 "actionType": + err = unpopulate(val, "ActionType", &r.ActionType) + 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 Resource. +func (r Resource) 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 Resource. +func (r *Resource) 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 ResourceAutoGenerated. +func (r ResourceAutoGenerated) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + 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 "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) + populateAny(objectMap, "parameters", r.Parameters) + populate(objectMap, "resources", r.Resources) + populate(objectMap, "$schema", r.Schema) + populateAny(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 @@ -1789,6 +2455,53 @@ 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]any) 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 477a5f6fa275..000000000000 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/operations_client_example_test.go +++ /dev/null @@ -1,244 +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. -// DO NOT EDIT. - -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/blob/a436672b07fb1fe276c203b086b3f0e0d0c4aa24/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() - clientFactory, err := armalertsmanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewOperationsClient().NewListPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.OperationsList = armalertsmanagement.OperationsList{ - // Value: []*armalertsmanagement.Operation{ - // { - // Name: to.Ptr("Microsoft.AlertsManagement/register/action"), - // Display: &armalertsmanagement.OperationDisplay{ - // Description: to.Ptr("Subscription Registration Action"), - // Operation: to.Ptr("Subscription Registration Action"), - // Provider: to.Ptr("Microsoft.AlertsManagement"), - // Resource: to.Ptr("Subscription"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.AlertsManagement/register/action"), - // Display: &armalertsmanagement.OperationDisplay{ - // Description: to.Ptr("Registers the subscription for the Microsoft Alerts Management"), - // Operation: to.Ptr("Register subscription"), - // Provider: to.Ptr("Microsoft.AlertsManagement"), - // Resource: to.Ptr("register"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.AlertsManagement/alerts/read"), - // Display: &armalertsmanagement.OperationDisplay{ - // Description: to.Ptr("Get all the alerts for the input filters."), - // Operation: to.Ptr("Read alerts"), - // Provider: to.Ptr("Microsoft.AlertsManagement"), - // Resource: to.Ptr("alerts"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.AlertsManagement/alerts/changestate/action"), - // Display: &armalertsmanagement.OperationDisplay{ - // Description: to.Ptr("Change the state of the alert."), - // Operation: to.Ptr("Resolve alerts"), - // Provider: to.Ptr("Microsoft.AlertsManagement"), - // Resource: to.Ptr("alerts"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.AlertsManagement/alerts/history/read"), - // Display: &armalertsmanagement.OperationDisplay{ - // Description: to.Ptr("Get history of the alert"), - // Operation: to.Ptr("Read alert history"), - // Provider: to.Ptr("Microsoft.AlertsManagement"), - // Resource: to.Ptr("alerts"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.AlertsManagement/smartDetectorAlertRules/write"), - // Display: &armalertsmanagement.OperationDisplay{ - // Description: to.Ptr("Create or update Smart Detector alert rule in a given subscription"), - // Operation: to.Ptr("Create Smart Detector alert rule"), - // Provider: to.Ptr("Microsoft.AlertsManagement"), - // Resource: to.Ptr("smartDetectorAlertRules"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.AlertsManagement/smartDetectorAlertRules/read"), - // Display: &armalertsmanagement.OperationDisplay{ - // Description: to.Ptr("Get all the Smart Detector alert rules for the input filters"), - // Operation: to.Ptr("Read Smart Detector alert rules"), - // Provider: to.Ptr("Microsoft.AlertsManagement"), - // Resource: to.Ptr("smartDetectorAlertRules"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.AlertsManagement/smartDetectorAlertRules/delete"), - // Display: &armalertsmanagement.OperationDisplay{ - // Description: to.Ptr("Delete Smart Detector alert rule in a given subscription"), - // Operation: to.Ptr("Delete Smart Detector alert rule"), - // Provider: to.Ptr("Microsoft.AlertsManagement"), - // Resource: to.Ptr("smartDetectorAlertRules"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.AlertsManagement/resourceHealthAlertRules/write"), - // Display: &armalertsmanagement.OperationDisplay{ - // Description: to.Ptr("Create or update Resource Health alert rule in a given subscription"), - // Operation: to.Ptr("Create Resource Health alert rule"), - // Provider: to.Ptr("Microsoft.AlertsManagement"), - // Resource: to.Ptr("resourceHealthAlertRules"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.AlertsManagement/resourceHealthAlertRules/read"), - // Display: &armalertsmanagement.OperationDisplay{ - // Description: to.Ptr("Get all the Resource Health alert rules for the input filters"), - // Operation: to.Ptr("Read Resource Health alert rules"), - // Provider: to.Ptr("Microsoft.AlertsManagement"), - // Resource: to.Ptr("resourceHealthAlertRules"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.AlertsManagement/resourceHealthAlertRules/delete"), - // Display: &armalertsmanagement.OperationDisplay{ - // Description: to.Ptr("Delete Resource Health alert rule in a given subscription"), - // Operation: to.Ptr("Delete Resource Health alert rule"), - // Provider: to.Ptr("Microsoft.AlertsManagement"), - // Resource: to.Ptr("resourceHealthAlertRules"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.AlertsManagement/migrateFromSmartDetection/read"), - // Display: &armalertsmanagement.OperationDisplay{ - // Description: to.Ptr("Get the status of an asynchronous Smart Detection to smart alerts migration process"), - // Operation: to.Ptr("Get Smart Detection Migration status"), - // Provider: to.Ptr("Microsoft.AlertsManagement"), - // Resource: to.Ptr("migrateFromSmartDetection"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.AlertsManagement/migrateFromSmartDetection/action"), - // Display: &armalertsmanagement.OperationDisplay{ - // Description: to.Ptr("Starts an asynchronous migration process of Smart Detection to smart alerts in an Application Insights resource"), - // Operation: to.Ptr("Migrate From Smart Detection"), - // Provider: to.Ptr("Microsoft.AlertsManagement"), - // Resource: to.Ptr("migrateFromSmartDetection"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.AlertsManagement/alertsSummary/read"), - // Display: &armalertsmanagement.OperationDisplay{ - // Description: to.Ptr("Get the summary of alerts"), - // Operation: to.Ptr("Read alerts summary"), - // Provider: to.Ptr("Microsoft.AlertsManagement"), - // Resource: to.Ptr("alertsSummary"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.AlertsManagement/smartGroups/read"), - // Display: &armalertsmanagement.OperationDisplay{ - // Description: to.Ptr("Get all the smart groups for the input filters"), - // Operation: to.Ptr("Read smart groups"), - // Provider: to.Ptr("Microsoft.AlertsManagement"), - // Resource: to.Ptr("smartGroups"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.AlertsManagement/smartGroups/changestate/action"), - // Display: &armalertsmanagement.OperationDisplay{ - // Description: to.Ptr("Change the state of the smart group"), - // Operation: to.Ptr("Read smart groups"), - // Provider: to.Ptr("Microsoft.AlertsManagement"), - // Resource: to.Ptr("smartGroups"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.AlertsManagement/smartGroups/history/read"), - // Display: &armalertsmanagement.OperationDisplay{ - // Description: to.Ptr("Get history of the smart group"), - // Operation: to.Ptr("Read smart group history"), - // Provider: to.Ptr("Microsoft.AlertsManagement"), - // Resource: to.Ptr("smartGroups"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.AlertsManagement/actionRules/read"), - // Display: &armalertsmanagement.OperationDisplay{ - // Description: to.Ptr("Get all the alert processing rules for the input filters."), - // Operation: to.Ptr("Read action rules"), - // Provider: to.Ptr("Microsoft.AlertsManagement"), - // Resource: to.Ptr("actionRules"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.AlertsManagement/actionRules/write"), - // Display: &armalertsmanagement.OperationDisplay{ - // Description: to.Ptr("Create or update alert processing rule in a given subscription"), - // Operation: to.Ptr("Write action rule"), - // Provider: to.Ptr("Microsoft.AlertsManagement"), - // Resource: to.Ptr("actionRules"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.AlertsManagement/actionRules/delete"), - // Display: &armalertsmanagement.OperationDisplay{ - // Description: to.Ptr("Delete alert processing rule in a given subscription."), - // Operation: to.Ptr("Delete action rule"), - // Provider: to.Ptr("Microsoft.AlertsManagement"), - // Resource: to.Ptr("actionRules"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.AlertsManagement/alertsMetaData/read"), - // Display: &armalertsmanagement.OperationDisplay{ - // Description: to.Ptr("Get alerts meta data for the input parameter."), - // Operation: to.Ptr("Read alerts meta data"), - // Provider: to.Ptr("Microsoft.AlertsManagement"), - // Resource: to.Ptr("Microsoft.AlertsManagement/alertsMetaData"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.AlertsManagement/Operations/read"), - // Display: &armalertsmanagement.OperationDisplay{ - // Description: to.Ptr("Reads the operations provided"), - // Operation: to.Ptr("Read operations"), - // Provider: to.Ptr("Microsoft.AlertsManagement"), - // Resource: to.Ptr("operations"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/prometheusrulegroups_client.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/prometheusrulegroups_client.go new file mode 100644 index 000000000000..510d6919e5cb --- /dev/null +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/prometheusrulegroups_client.go @@ -0,0 +1,383 @@ +//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" + "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 { + internal *arm.Client + subscriptionID string +} + +// 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) { + cl, err := arm.NewClient(moduleName+".PrometheusRuleGroupsClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &PrometheusRuleGroupsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + 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 2023-03-01 +// - 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.internal.Pipeline().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.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-03-01") + 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 2023-03-01 +// - 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.internal.Pipeline().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.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-03-01") + 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 2023-03-01 +// - 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.internal.Pipeline().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.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-03-01") + 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 2023-03-01 +// - 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.internal.Pipeline().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.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-03-01") + 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 all rule group definitions in a subscription. +// +// Generated from API version 2023-03-01 +// - 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.internal.Pipeline().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.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-03-01") + 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 2023-03-01 +// - 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 PrometheusRuleGroupResourcePatchParameters, options *PrometheusRuleGroupsClientUpdateOptions) (PrometheusRuleGroupsClientUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, ruleGroupName, parameters, options) + if err != nil { + return PrometheusRuleGroupsClientUpdateResponse{}, err + } + resp, err := client.internal.Pipeline().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 PrometheusRuleGroupResourcePatchParameters, 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.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-03-01") + 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 dcc088cb29ea..617be2caa061 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/response_types.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/response_types.go @@ -50,6 +50,16 @@ 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 @@ -85,6 +95,36 @@ 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 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 bcf81100b02b..000000000000 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/smartgroups_client_example_test.go +++ /dev/null @@ -1,355 +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. -// DO NOT EDIT. - -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/blob/a436672b07fb1fe276c203b086b3f0e0d0c4aa24/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() - clientFactory, err := armalertsmanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewSmartGroupsClient().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() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.SmartGroupsList = armalertsmanagement.SmartGroupsList{ - // Value: []*armalertsmanagement.SmartGroup{ - // { - // Name: to.Ptr("cpu alert"), - // Type: to.Ptr("Microsoft.AlertsManagement/smartGroups"), - // ID: to.Ptr("/subscriptions/dd91de05-d791-4ceb-b6dc-988682dc7d72/providers/Microsoft.AlertsManagement/smartGroups/a808445e-bb38-4751-85c2-1b109ccc1059"), - // Properties: &armalertsmanagement.SmartGroupProperties{ - // AlertSeverities: []*armalertsmanagement.SmartGroupAggregatedProperty{ - // { - // Name: to.Ptr("Sev3"), - // Count: to.Ptr[int64](1942), - // }}, - // AlertStates: []*armalertsmanagement.SmartGroupAggregatedProperty{ - // { - // Name: to.Ptr("New"), - // Count: to.Ptr[int64](1941), - // }, - // { - // Name: to.Ptr("Acknowledged"), - // Count: to.Ptr[int64](1), - // }}, - // AlertsCount: to.Ptr[int64](1942), - // LastModifiedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-13T06:30:09Z"); return t}()), - // LastModifiedUserName: to.Ptr("System"), - // MonitorConditions: []*armalertsmanagement.SmartGroupAggregatedProperty{ - // { - // Name: to.Ptr("Fired"), - // Count: to.Ptr[int64](1942), - // }}, - // MonitorServices: []*armalertsmanagement.SmartGroupAggregatedProperty{ - // { - // Name: to.Ptr("Application Insights"), - // Count: to.Ptr[int64](1942), - // }}, - // ResourceGroups: []*armalertsmanagement.SmartGroupAggregatedProperty{ - // { - // Name: to.Ptr("alertscorrelationrg"), - // Count: to.Ptr[int64](1942), - // }}, - // ResourceTypes: []*armalertsmanagement.SmartGroupAggregatedProperty{ - // { - // Name: to.Ptr("components"), - // Count: to.Ptr[int64](1942), - // }}, - // Resources: []*armalertsmanagement.SmartGroupAggregatedProperty{ - // { - // Name: to.Ptr("/subscriptions/dd91de05-d791-4ceb-b6dc-988682dc7d72/resourcegroups/alertscorrelationrg/providers/microsoft.insights/components/alertscorrelationworkerrole_int"), - // Count: to.Ptr[int64](1942), - // }}, - // Severity: to.Ptr(armalertsmanagement.SeveritySev3), - // SmartGroupState: to.Ptr(armalertsmanagement.StateNew), - // StartDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-06T12:35:09Z"); return t}()), - // }, - // }, - // { - // Name: to.Ptr("CPU Alert"), - // Type: to.Ptr("Microsoft.AlertsManagement/smartGroups"), - // ID: to.Ptr("/subscriptions/dd91de05-d791-4ceb-b6dc-988682dc7d72/providers/Microsoft.AlertsManagement/smartGroups/01114c7c-769f-4fd4-b6fa-ab77693b83cd"), - // Properties: &armalertsmanagement.SmartGroupProperties{ - // AlertSeverities: []*armalertsmanagement.SmartGroupAggregatedProperty{ - // { - // Name: to.Ptr("Sev0"), - // Count: to.Ptr[int64](6984), - // }, - // { - // Name: to.Ptr("Sev1"), - // Count: to.Ptr[int64](6927), - // }}, - // AlertStates: []*armalertsmanagement.SmartGroupAggregatedProperty{ - // { - // Name: to.Ptr("New"), - // Count: to.Ptr[int64](15358), - // }, - // { - // Name: to.Ptr("Acknowledged"), - // Count: to.Ptr[int64](12), - // }, - // { - // Name: to.Ptr("Closed"), - // Count: to.Ptr[int64](4), - // }}, - // AlertsCount: to.Ptr[int64](15374), - // LastModifiedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-13T06:29:01Z"); return t}()), - // LastModifiedUserName: to.Ptr("System"), - // MonitorConditions: []*armalertsmanagement.SmartGroupAggregatedProperty{ - // { - // Name: to.Ptr("Fired"), - // Count: to.Ptr[int64](15374), - // }}, - // MonitorServices: []*armalertsmanagement.SmartGroupAggregatedProperty{ - // { - // Name: to.Ptr("Log Analytics"), - // Count: to.Ptr[int64](13911), - // }}, - // ResourceGroups: []*armalertsmanagement.SmartGroupAggregatedProperty{ - // { - // Name: to.Ptr("mms-eus"), - // Count: to.Ptr[int64](15374), - // }}, - // ResourceTypes: []*armalertsmanagement.SmartGroupAggregatedProperty{ - // { - // Name: to.Ptr("microsoft.operationalinsights/workspaces"), - // Count: to.Ptr[int64](6912), - // }, - // { - // Name: to.Ptr("workspaces"), - // Count: to.Ptr[int64](8462), - // }}, - // Resources: []*armalertsmanagement.SmartGroupAggregatedProperty{ - // { - // Name: to.Ptr("/subscriptions/dd91de05-d791-4ceb-b6dc-988682dc7d72/resourcegroups/mms-eus/providers/microsoft.operationalinsights/workspaces/alertsint"), - // Count: to.Ptr[int64](15374), - // }}, - // Severity: to.Ptr(armalertsmanagement.SeveritySev0), - // SmartGroupState: to.Ptr(armalertsmanagement.StateAcknowledged), - // StartDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-17T10:18:44.2020997Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a436672b07fb1fe276c203b086b3f0e0d0c4aa24/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() - clientFactory, err := armalertsmanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSmartGroupsClient().GetByID(ctx, "603675da-9851-4b26-854a-49fc53d32715", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.SmartGroup = armalertsmanagement.SmartGroup{ - // Name: to.Ptr("cpu alert"), - // Type: to.Ptr("Microsoft.AlertsManagement/smartGroups"), - // ID: to.Ptr("/subscriptions/dd91de05-d791-4ceb-b6dc-988682dc7d72/providers/Microsoft.AlertsManagement/smartGroups/a808445e-bb38-4751-85c2-1b109ccc1059"), - // Properties: &armalertsmanagement.SmartGroupProperties{ - // AlertSeverities: []*armalertsmanagement.SmartGroupAggregatedProperty{ - // { - // Name: to.Ptr("Sev3"), - // Count: to.Ptr[int64](1942), - // }}, - // AlertStates: []*armalertsmanagement.SmartGroupAggregatedProperty{ - // { - // Name: to.Ptr("New"), - // Count: to.Ptr[int64](1941), - // }, - // { - // Name: to.Ptr("Acknowledged"), - // Count: to.Ptr[int64](1), - // }}, - // AlertsCount: to.Ptr[int64](1942), - // LastModifiedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-13T06:30:09Z"); return t}()), - // LastModifiedUserName: to.Ptr("System"), - // MonitorConditions: []*armalertsmanagement.SmartGroupAggregatedProperty{ - // { - // Name: to.Ptr("Fired"), - // Count: to.Ptr[int64](1942), - // }}, - // MonitorServices: []*armalertsmanagement.SmartGroupAggregatedProperty{ - // { - // Name: to.Ptr("Application Insights"), - // Count: to.Ptr[int64](1942), - // }}, - // ResourceGroups: []*armalertsmanagement.SmartGroupAggregatedProperty{ - // { - // Name: to.Ptr("alertscorrelationrg"), - // Count: to.Ptr[int64](1942), - // }}, - // ResourceTypes: []*armalertsmanagement.SmartGroupAggregatedProperty{ - // { - // Name: to.Ptr("components"), - // Count: to.Ptr[int64](1942), - // }}, - // Resources: []*armalertsmanagement.SmartGroupAggregatedProperty{ - // { - // Name: to.Ptr("/subscriptions/dd91de05-d791-4ceb-b6dc-988682dc7d72/resourcegroups/alertscorrelationrg/providers/microsoft.insights/components/alertscorrelationworkerrole_int"), - // Count: to.Ptr[int64](1942), - // }}, - // Severity: to.Ptr(armalertsmanagement.SeveritySev3), - // SmartGroupState: to.Ptr(armalertsmanagement.StateNew), - // StartDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-06T12:35:09Z"); return t}()), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a436672b07fb1fe276c203b086b3f0e0d0c4aa24/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() - clientFactory, err := armalertsmanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSmartGroupsClient().ChangeState(ctx, "a808445e-bb38-4751-85c2-1b109ccc1059", armalertsmanagement.AlertStateAcknowledged, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.SmartGroup = armalertsmanagement.SmartGroup{ - // Name: to.Ptr("cpu alert"), - // Type: to.Ptr("Microsoft.AlertsManagement/smartGroups"), - // ID: to.Ptr("/subscriptions/dd91de05-d791-4ceb-b6dc-988682dc7d72/providers/Microsoft.AlertsManagement/smartGroups/a808445e-bb38-4751-85c2-1b109ccc1059"), - // Properties: &armalertsmanagement.SmartGroupProperties{ - // AlertSeverities: []*armalertsmanagement.SmartGroupAggregatedProperty{ - // { - // Name: to.Ptr("Sev3"), - // Count: to.Ptr[int64](1942), - // }}, - // AlertStates: []*armalertsmanagement.SmartGroupAggregatedProperty{ - // { - // Name: to.Ptr("New"), - // Count: to.Ptr[int64](1941), - // }, - // { - // Name: to.Ptr("Acknowledged"), - // Count: to.Ptr[int64](1), - // }}, - // AlertsCount: to.Ptr[int64](1942), - // LastModifiedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-13T06:30:09Z"); return t}()), - // LastModifiedUserName: to.Ptr("System"), - // MonitorConditions: []*armalertsmanagement.SmartGroupAggregatedProperty{ - // { - // Name: to.Ptr("Fired"), - // Count: to.Ptr[int64](1942), - // }}, - // MonitorServices: []*armalertsmanagement.SmartGroupAggregatedProperty{ - // { - // Name: to.Ptr("Application Insights"), - // Count: to.Ptr[int64](1942), - // }}, - // ResourceGroups: []*armalertsmanagement.SmartGroupAggregatedProperty{ - // { - // Name: to.Ptr("alertscorrelationrg"), - // Count: to.Ptr[int64](1942), - // }}, - // ResourceTypes: []*armalertsmanagement.SmartGroupAggregatedProperty{ - // { - // Name: to.Ptr("components"), - // Count: to.Ptr[int64](1942), - // }}, - // Resources: []*armalertsmanagement.SmartGroupAggregatedProperty{ - // { - // Name: to.Ptr("/subscriptions/dd91de05-d791-4ceb-b6dc-988682dc7d72/resourcegroups/alertscorrelationrg/providers/microsoft.insights/components/alertscorrelationworkerrole_int"), - // Count: to.Ptr[int64](1942), - // }}, - // Severity: to.Ptr(armalertsmanagement.SeveritySev3), - // SmartGroupState: to.Ptr(armalertsmanagement.StateAcknowledged), - // StartDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-06T12:35:09Z"); return t}()), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a436672b07fb1fe276c203b086b3f0e0d0c4aa24/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() - clientFactory, err := armalertsmanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSmartGroupsClient().GetHistory(ctx, "a808445e-bb38-4751-85c2-1b109ccc1059", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.SmartGroupModification = armalertsmanagement.SmartGroupModification{ - // Name: to.Ptr("cpu alert"), - // Type: to.Ptr("Microsoft.AlertsManagement/alerts"), - // ID: to.Ptr("/subscriptions/9e261de7-c804-4b9d-9ebf-6f50fe350a9a/providers/Microsoft.AlertsManagement/smartGroups/a808445e-bb38-4751-85c2-1b109ccc1059/history/default"), - // Properties: &armalertsmanagement.SmartGroupModificationProperties{ - // Modifications: []*armalertsmanagement.SmartGroupModificationItem{ - // { - // Description: to.Ptr("New Smart Group is created"), - // Comments: to.Ptr(""), - // ModificationEvent: to.Ptr(armalertsmanagement.SmartGroupModificationEventSmartGroupCreated), - // ModifiedAt: to.Ptr("2018-06-06T12:35:09Z"), - // ModifiedBy: to.Ptr("System"), - // NewValue: to.Ptr(""), - // OldValue: to.Ptr(""), - // }}, - // SmartGroupID: to.Ptr("a808445e-bb38-4751-85c2-1b109ccc1059"), - // }, - // } -}