From b2dc209fc621a53c33e2e24edf90552ae4bd543b Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Tue, 13 Feb 2024 09:29:28 +0000 Subject: [PATCH] CodeGen from PR 27738 in Azure/azure-rest-api-specs Merge c3983034acd115a9c54499306af937b48971149f into 0c885c14263db5ebfe87e45c767d44a16f086a43 --- .../armalertsmanagement/CHANGELOG.md | 75 + .../armalertsmanagement/README.md | 2 +- .../alertprocessingrules_client.go | 24 +- ...lertprocessingrules_client_example_test.go | 961 ----------- .../alertrulerecommendations_client.go | 154 ++ .../armalertsmanagement/alerts_client.go | 219 ++- .../alerts_client_example_test.go | 516 ------ .../armalertsmanagement/autorest.md | 6 +- .../armalertsmanagement/client_factory.go | 14 +- .../armalertsmanagement/constants.go | 138 +- .../fake/alertrulerecommendations_server.go | 154 ++ .../armalertsmanagement/fake/alerts_server.go | 145 +- .../fake/prometheusrulegroups_server.go | 307 ++++ .../fake/server_factory.go | 34 +- .../armalertsmanagement/go.mod | 2 +- .../armalertsmanagement/interfaces.go | 21 +- .../armalertsmanagement/models.go | 581 ++++++- .../armalertsmanagement/models_serde.go | 1455 +++++++++++++++-- .../armalertsmanagement/operations_client.go | 4 +- .../operations_client_example_test.go | 244 --- .../armalertsmanagement/options.go | 57 +- .../polymorphic_helpers.go | 46 + .../prometheusrulegroups_client.go | 419 +++++ .../armalertsmanagement/response_types.go | 59 + .../smartgroups_client_example_test.go | 355 ---- 25 files changed, 3690 insertions(+), 2302 deletions(-) delete mode 100644 sdk/resourcemanager/alertsmanagement/armalertsmanagement/alertprocessingrules_client_example_test.go create mode 100644 sdk/resourcemanager/alertsmanagement/armalertsmanagement/alertrulerecommendations_client.go delete mode 100644 sdk/resourcemanager/alertsmanagement/armalertsmanagement/alerts_client_example_test.go create mode 100644 sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/alertrulerecommendations_server.go create mode 100644 sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/prometheusrulegroups_server.go delete mode 100644 sdk/resourcemanager/alertsmanagement/armalertsmanagement/operations_client_example_test.go create mode 100644 sdk/resourcemanager/alertsmanagement/armalertsmanagement/prometheusrulegroups_client.go delete mode 100644 sdk/resourcemanager/alertsmanagement/armalertsmanagement/smartgroups_client_example_test.go diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/CHANGELOG.md b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/CHANGELOG.md index 2702dd0a90d8..bd15940f62cf 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/CHANGELOG.md +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/CHANGELOG.md @@ -1,5 +1,80 @@ # Release History +## 0.10.0 (2024-02-13) +### Breaking Changes + +- Function `*AlertsClient.ChangeState` parameter(s) have been changed from `(context.Context, string, AlertState, *AlertsClientChangeStateOptions)` to `(context.Context, string, string, AlertState, *AlertsClientChangeStateOptions)` +- Function `*AlertsClient.GetByID` parameter(s) have been changed from `(context.Context, string, *AlertsClientGetByIDOptions)` to `(context.Context, string, string, *AlertsClientGetByIDOptions)` +- Function `*AlertsClient.GetHistory` parameter(s) have been changed from `(context.Context, string, *AlertsClientGetHistoryOptions)` to `(context.Context, string, string, *AlertsClientGetHistoryOptions)` +- Function `*AlertsClient.GetSummary` parameter(s) have been changed from `(context.Context, AlertsSummaryGroupByFields, *AlertsClientGetSummaryOptions)` to `(context.Context, string, AlertsSummaryGroupByFields, *AlertsClientGetSummaryOptions)` +- Function `*AlertsClient.NewGetAllPager` parameter(s) have been changed from `(*AlertsClientGetAllOptions)` to `(string, *AlertsClientGetAllOptions)` +- 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 `*ErrorDetailAutoGenerated` + +### Features Added + +- New value `ActionTypeCorrelateAlerts` added to enum type `ActionType` +- New value `MonitorServiceResourceHealth` added to enum type `MonitorService` +- 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 enum type `NotificationsForCorrelatedAlerts` with values `NotificationsForCorrelatedAlertsNotifyAlways`, `NotificationsForCorrelatedAlertsSuppressAlways` +- New enum type `Status` with values `StatusFailed`, `StatusSucceeded` +- New enum type `Type` with values `TypePrometheusInstantQuery`, `TypePrometheusRangeQuery` +- New function `*AlertEnrichmentItem.GetAlertEnrichmentItem() *AlertEnrichmentItem` +- New function `NewAlertRuleRecommendationsClient(string, azcore.TokenCredential, *arm.ClientOptions) (*AlertRuleRecommendationsClient, error)` +- New function `*AlertRuleRecommendationsClient.NewListByResourcePager(string, *AlertRuleRecommendationsClientListByResourceOptions) *runtime.Pager[AlertRuleRecommendationsClientListByResourceResponse]` +- New function `*AlertRuleRecommendationsClient.NewListByTargetTypePager(string, *AlertRuleRecommendationsClientListByTargetTypeOptions) *runtime.Pager[AlertRuleRecommendationsClientListByTargetTypeResponse]` +- New function `*AlertsClient.GetEnrichments(context.Context, string, string, *AlertsClientGetEnrichmentsOptions) (AlertsClientGetEnrichmentsResponse, error)` +- New function `*AlertsClient.NewListEnrichmentsPager(string, string, *AlertsClientListEnrichmentsOptions) *runtime.Pager[AlertsClientListEnrichmentsResponse]` +- New function `*ClientFactory.NewAlertRuleRecommendationsClient() *AlertRuleRecommendationsClient` +- New function `*ClientFactory.NewPrometheusRuleGroupsClient() *PrometheusRuleGroupsClient` +- New function `*CorrelateAlerts.GetAction() *Action` +- New function `*PrometheusEnrichmentItem.GetAlertEnrichmentItem() *AlertEnrichmentItem` +- New function `*PrometheusEnrichmentItem.GetPrometheusEnrichmentItem() *PrometheusEnrichmentItem` +- New function `*PrometheusInstantQuery.GetAlertEnrichmentItem() *AlertEnrichmentItem` +- New function `*PrometheusInstantQuery.GetPrometheusEnrichmentItem() *PrometheusEnrichmentItem` +- New function `*PrometheusRangeQuery.GetAlertEnrichmentItem() *AlertEnrichmentItem` +- New function `*PrometheusRangeQuery.GetPrometheusEnrichmentItem() *PrometheusEnrichmentItem` +- 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 `AlertEnrichmentProperties` +- New struct `AlertEnrichmentResponse` +- New struct `AlertEnrichmentsList` +- New struct `AlertRuleRecommendationProperties` +- New struct `AlertRuleRecommendationResource` +- New struct `AlertRuleRecommendationsListResponse` +- New struct `Comments` +- New struct `CorrelateAlerts` +- New struct `CorrelateBy` +- New struct `ErrorAdditionalInfo` +- New struct `ErrorDetail` +- New struct `ErrorDetailAutoGenerated` +- New struct `ErrorResponseAutoGenerated3` +- New struct `ErrorResponseAutoGenerated4` +- New struct `PrometheusInstantQuery` +- New struct `PrometheusRangeQuery` +- 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 `ResourceAutoGenerated2` +- New struct `RuleArmTemplate` +- New struct `TrackedResource` +- New field `SystemData` in struct `Resource` + + ## 0.9.0 (2023-11-24) ### Features Added diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/README.md b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/README.md index 9d6f92f683c8..ac93f95d5c34 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/README.md +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/README.md @@ -57,7 +57,7 @@ clientFactory, err := armalertsmanagement.NewClientFactory(, cr A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. ```go -client := clientFactory.NewAlertsClient() +client := clientFactory.NewAlertProcessingRulesClient() ``` ## Fakes diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alertprocessingrules_client.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alertprocessingrules_client.go index e61ee2fa2ff7..f970b3a1d589 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alertprocessingrules_client.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alertprocessingrules_client.go @@ -46,7 +46,7 @@ func NewAlertProcessingRulesClient(subscriptionID string, credential azcore.Toke // CreateOrUpdate - Create or update an alert processing rule. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-08-08 +// Generated from API version 2023-05-01-preview // - resourceGroupName - Resource group name where the resource is created. // - alertProcessingRuleName - The name of the alert processing rule that needs to be created/updated. // - alertProcessingRule - Alert processing rule to be created/updated. @@ -94,7 +94,7 @@ func (client *AlertProcessingRulesClient) createOrUpdateCreateRequest(ctx contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-08-08") + reqQP.Set("api-version", "2023-05-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, alertProcessingRule); err != nil { @@ -118,7 +118,7 @@ func (client *AlertProcessingRulesClient) createOrUpdateHandleResponse(resp *htt // Delete - Delete an alert processing rule. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-08-08 +// Generated from API version 2023-05-01-preview // - resourceGroupName - Resource group name where the resource is created. // - alertProcessingRuleName - The name of the alert processing rule that needs to be deleted. // - options - AlertProcessingRulesClientDeleteOptions contains the optional parameters for the AlertProcessingRulesClient.Delete @@ -165,7 +165,7 @@ func (client *AlertProcessingRulesClient) deleteCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-08-08") + reqQP.Set("api-version", "2023-05-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -183,7 +183,7 @@ func (client *AlertProcessingRulesClient) deleteHandleResponse(resp *http.Respon // GetByName - Get an alert processing rule by name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-08-08 +// Generated from API version 2023-05-01-preview // - resourceGroupName - Resource group name where the resource is created. // - alertProcessingRuleName - The name of the alert processing rule that needs to be fetched. // - options - AlertProcessingRulesClientGetByNameOptions contains the optional parameters for the AlertProcessingRulesClient.GetByName @@ -230,7 +230,7 @@ func (client *AlertProcessingRulesClient) getByNameCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-08-08") + reqQP.Set("api-version", "2023-05-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -250,7 +250,7 @@ func (client *AlertProcessingRulesClient) getByNameHandleResponse(resp *http.Res // NewListByResourceGroupPager - List all alert processing rules in a resource group. // -// Generated from API version 2021-08-08 +// Generated from API version 2023-05-01-preview // - resourceGroupName - Resource group name where the resource is created. // - options - AlertProcessingRulesClientListByResourceGroupOptions contains the optional parameters for the AlertProcessingRulesClient.NewListByResourceGroupPager // method. @@ -293,7 +293,7 @@ func (client *AlertProcessingRulesClient) listByResourceGroupCreateRequest(ctx c return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-08-08") + reqQP.Set("api-version", "2023-05-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -313,7 +313,7 @@ func (client *AlertProcessingRulesClient) listByResourceGroupHandleResponse(resp // NewListBySubscriptionPager - List all alert processing rules in a subscription. // -// Generated from API version 2021-08-08 +// Generated from API version 2023-05-01-preview // - options - AlertProcessingRulesClientListBySubscriptionOptions contains the optional parameters for the AlertProcessingRulesClient.NewListBySubscriptionPager // method. func (client *AlertProcessingRulesClient) NewListBySubscriptionPager(options *AlertProcessingRulesClientListBySubscriptionOptions) *runtime.Pager[AlertProcessingRulesClientListBySubscriptionResponse] { @@ -351,7 +351,7 @@ func (client *AlertProcessingRulesClient) listBySubscriptionCreateRequest(ctx co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-08-08") + reqQP.Set("api-version", "2023-05-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -372,7 +372,7 @@ func (client *AlertProcessingRulesClient) listBySubscriptionHandleResponse(resp // Update - Enable, disable, or update tags for an alert processing rule. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-08-08 +// Generated from API version 2023-05-01-preview // - resourceGroupName - Resource group name where the resource is created. // - alertProcessingRuleName - The name that needs to be updated. // - alertProcessingRulePatch - Parameters supplied to the operation. @@ -420,7 +420,7 @@ func (client *AlertProcessingRulesClient) updateCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-08-08") + reqQP.Set("api-version", "2023-05-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, alertProcessingRulePatch); err != nil { diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alertprocessingrules_client_example_test.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alertprocessingrules_client_example_test.go deleted file mode 100644 index 734cc9e11a65..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:09.000Z"); 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:09.000Z"); 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:09.000Z"); 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:09.000Z"); 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:09.000Z"); 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:09.000Z"); 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:09.000Z"); 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:09.000Z"); 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:09.000Z"); 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:09.000Z"); 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:09.000Z"); 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:34.000Z"); 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:09.000Z"); 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:09.000Z"); 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:29.000Z"); 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:09.000Z"); 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:09.000Z"); 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:09.000Z"); 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:09.000Z"); 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:09.000Z"); 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:09.000Z"); 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:09.000Z"); 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:09.000Z"); 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:09.000Z"); 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..823d3766348c --- /dev/null +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alertrulerecommendations_client.go @@ -0,0 +1,154 @@ +//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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +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 +} + +// NewAlertRuleRecommendationsClient creates a new instance of AlertRuleRecommendationsClient 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 NewAlertRuleRecommendationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AlertRuleRecommendationsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &AlertRuleRecommendationsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// NewListByResourcePager - Retrieve alert rule recommendations for a resource. +// +// Generated from API version 2023-08-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) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "AlertRuleRecommendationsClient.NewListByResourcePager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceCreateRequest(ctx, resourceURI, options) + }, nil) + if err != nil { + return AlertRuleRecommendationsClientListByResourceResponse{}, err + } + return client.listByResourceHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// 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-08-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-08-01-preview +// - targetType - The recommendations target type. +// - options - AlertRuleRecommendationsClientListByTargetTypeOptions contains the optional parameters for the AlertRuleRecommendationsClient.NewListByTargetTypePager +// method. +func (client *AlertRuleRecommendationsClient) NewListByTargetTypePager(targetType string, 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) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "AlertRuleRecommendationsClient.NewListByTargetTypePager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByTargetTypeCreateRequest(ctx, targetType, options) + }, nil) + if err != nil { + return AlertRuleRecommendationsClientListByTargetTypeResponse{}, err + } + return client.listByTargetTypeHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByTargetTypeCreateRequest creates the ListByTargetType request. +func (client *AlertRuleRecommendationsClient) listByTargetTypeCreateRequest(ctx context.Context, targetType string, 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-08-01-preview") + reqQP.Set("targetType", 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 48bfbe95fa53..31aa482d75bd 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alerts_client.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alerts_client.go @@ -24,22 +24,19 @@ import ( // AlertsClient contains the methods for the Alerts group. // Don't use this type directly, use NewAlertsClient() instead. type AlertsClient struct { - internal *arm.Client - subscriptionID string + internal *arm.Client } // NewAlertsClient creates a new instance of AlertsClient with the specified values. -// - subscriptionID - The ID of the target subscription. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. -func NewAlertsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AlertsClient, error) { +func NewAlertsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*AlertsClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } client := &AlertsClient{ - subscriptionID: subscriptionID, - internal: cl, + internal: cl, } return client, nil } @@ -47,17 +44,18 @@ func NewAlertsClient(subscriptionID string, credential azcore.TokenCredential, o // ChangeState - Change the state of an alert. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2019-05-05-preview +// Generated from API version 2023-07-12-preview +// - scope - scope here is resourceId for which alert is created. // - alertID - Unique ID of an alert instance. // - newState - New state of the alert. // - options - AlertsClientChangeStateOptions contains the optional parameters for the AlertsClient.ChangeState method. -func (client *AlertsClient) ChangeState(ctx context.Context, alertID string, newState AlertState, options *AlertsClientChangeStateOptions) (AlertsClientChangeStateResponse, error) { +func (client *AlertsClient) ChangeState(ctx context.Context, scope string, alertID string, newState AlertState, options *AlertsClientChangeStateOptions) (AlertsClientChangeStateResponse, error) { var err error const operationName = "AlertsClient.ChangeState" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.changeStateCreateRequest(ctx, alertID, newState, options) + req, err := client.changeStateCreateRequest(ctx, scope, alertID, newState, options) if err != nil { return AlertsClientChangeStateResponse{}, err } @@ -74,12 +72,9 @@ func (client *AlertsClient) ChangeState(ctx context.Context, alertID string, new } // changeStateCreateRequest creates the ChangeState request. -func (client *AlertsClient) changeStateCreateRequest(ctx context.Context, alertID string, newState AlertState, options *AlertsClientChangeStateOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/alerts/{alertId}/changestate" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) +func (client *AlertsClient) changeStateCreateRequest(ctx context.Context, scope string, alertID string, newState AlertState, options *AlertsClientChangeStateOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.AlertsManagement/alerts/{alertId}/changestate" + urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) if alertID == "" { return nil, errors.New("parameter alertID cannot be empty") } @@ -89,7 +84,7 @@ func (client *AlertsClient) changeStateCreateRequest(ctx context.Context, alertI return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2019-05-05-preview") + reqQP.Set("api-version", "2023-07-12-preview") reqQP.Set("newState", string(newState)) req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} @@ -115,9 +110,10 @@ func (client *AlertsClient) changeStateHandleResponse(resp *http.Response) (Aler // time range). The results can then be sorted on the basis specific fields, with the default being // lastModifiedDateTime. // -// Generated from API version 2019-05-05-preview +// Generated from API version 2023-07-12-preview +// - scope - scope here is resourceId for which alert is created. // - options - AlertsClientGetAllOptions contains the optional parameters for the AlertsClient.NewGetAllPager method. -func (client *AlertsClient) NewGetAllPager(options *AlertsClientGetAllOptions) *runtime.Pager[AlertsClientGetAllResponse] { +func (client *AlertsClient) NewGetAllPager(scope string, options *AlertsClientGetAllOptions) *runtime.Pager[AlertsClientGetAllResponse] { return runtime.NewPager(runtime.PagingHandler[AlertsClientGetAllResponse]{ More: func(page AlertsClientGetAllResponse) bool { return page.NextLink != nil && len(*page.NextLink) > 0 @@ -129,7 +125,7 @@ func (client *AlertsClient) NewGetAllPager(options *AlertsClientGetAllOptions) * nextLink = *page.NextLink } resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.getAllCreateRequest(ctx, options) + return client.getAllCreateRequest(ctx, scope, options) }, nil) if err != nil { return AlertsClientGetAllResponse{}, err @@ -141,12 +137,9 @@ func (client *AlertsClient) NewGetAllPager(options *AlertsClientGetAllOptions) * } // getAllCreateRequest creates the GetAll request. -func (client *AlertsClient) getAllCreateRequest(ctx context.Context, options *AlertsClientGetAllOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/alerts" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) +func (client *AlertsClient) getAllCreateRequest(ctx context.Context, scope string, options *AlertsClientGetAllOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.AlertsManagement/alerts" + urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err @@ -203,7 +196,7 @@ func (client *AlertsClient) getAllCreateRequest(ctx context.Context, options *Al if options != nil && options.CustomTimeRange != nil { reqQP.Set("customTimeRange", *options.CustomTimeRange) } - reqQP.Set("api-version", "2019-05-05-preview") + reqQP.Set("api-version", "2023-07-12-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -221,16 +214,17 @@ func (client *AlertsClient) getAllHandleResponse(resp *http.Response) (AlertsCli // GetByID - Get information related to a specific alert // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2019-05-05-preview +// Generated from API version 2023-07-12-preview +// - scope - scope here is resourceId for which alert is created. // - alertID - Unique ID of an alert instance. // - options - AlertsClientGetByIDOptions contains the optional parameters for the AlertsClient.GetByID method. -func (client *AlertsClient) GetByID(ctx context.Context, alertID string, options *AlertsClientGetByIDOptions) (AlertsClientGetByIDResponse, error) { +func (client *AlertsClient) GetByID(ctx context.Context, scope string, alertID string, options *AlertsClientGetByIDOptions) (AlertsClientGetByIDResponse, error) { var err error const operationName = "AlertsClient.GetByID" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.getByIDCreateRequest(ctx, alertID, options) + req, err := client.getByIDCreateRequest(ctx, scope, alertID, options) if err != nil { return AlertsClientGetByIDResponse{}, err } @@ -247,12 +241,9 @@ func (client *AlertsClient) GetByID(ctx context.Context, alertID string, options } // getByIDCreateRequest creates the GetByID request. -func (client *AlertsClient) getByIDCreateRequest(ctx context.Context, alertID string, options *AlertsClientGetByIDOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/alerts/{alertId}" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) +func (client *AlertsClient) getByIDCreateRequest(ctx context.Context, scope string, alertID string, options *AlertsClientGetByIDOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.AlertsManagement/alerts/{alertId}" + urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) if alertID == "" { return nil, errors.New("parameter alertID cannot be empty") } @@ -262,7 +253,7 @@ func (client *AlertsClient) getByIDCreateRequest(ctx context.Context, alertID st return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2019-05-05-preview") + reqQP.Set("api-version", "2023-07-12-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -277,20 +268,78 @@ func (client *AlertsClient) getByIDHandleResponse(resp *http.Response) (AlertsCl return result, nil } +// GetEnrichments - Get the enrichments of an alert. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-07-12-preview +// - scope - scope here is resourceId for which alert is created. +// - alertID - Unique ID of an alert instance. +// - options - AlertsClientGetEnrichmentsOptions contains the optional parameters for the AlertsClient.GetEnrichments method. +func (client *AlertsClient) GetEnrichments(ctx context.Context, scope string, alertID string, options *AlertsClientGetEnrichmentsOptions) (AlertsClientGetEnrichmentsResponse, error) { + var err error + const operationName = "AlertsClient.GetEnrichments" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getEnrichmentsCreateRequest(ctx, scope, alertID, options) + if err != nil { + return AlertsClientGetEnrichmentsResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return AlertsClientGetEnrichmentsResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AlertsClientGetEnrichmentsResponse{}, err + } + resp, err := client.getEnrichmentsHandleResponse(httpResp) + return resp, err +} + +// getEnrichmentsCreateRequest creates the GetEnrichments request. +func (client *AlertsClient) getEnrichmentsCreateRequest(ctx context.Context, scope string, alertID string, options *AlertsClientGetEnrichmentsOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.AlertsManagement/alerts/{alertId}/enrichments/default" + urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) + if alertID == "" { + return nil, errors.New("parameter alertID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{alertId}", url.PathEscape(alertID)) + 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-07-12-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getEnrichmentsHandleResponse handles the GetEnrichments response. +func (client *AlertsClient) getEnrichmentsHandleResponse(resp *http.Response) (AlertsClientGetEnrichmentsResponse, error) { + result := AlertsClientGetEnrichmentsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AlertEnrichmentResponse); err != nil { + return AlertsClientGetEnrichmentsResponse{}, err + } + return result, nil +} + // GetHistory - Get the history of an alert, which captures any monitor condition changes (Fired/Resolved) and alert state // changes (New/Acknowledged/Closed). // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2019-05-05-preview +// Generated from API version 2023-07-12-preview +// - scope - scope here is resourceId for which alert is created. // - alertID - Unique ID of an alert instance. // - options - AlertsClientGetHistoryOptions contains the optional parameters for the AlertsClient.GetHistory method. -func (client *AlertsClient) GetHistory(ctx context.Context, alertID string, options *AlertsClientGetHistoryOptions) (AlertsClientGetHistoryResponse, error) { +func (client *AlertsClient) GetHistory(ctx context.Context, scope string, alertID string, options *AlertsClientGetHistoryOptions) (AlertsClientGetHistoryResponse, error) { var err error const operationName = "AlertsClient.GetHistory" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.getHistoryCreateRequest(ctx, alertID, options) + req, err := client.getHistoryCreateRequest(ctx, scope, alertID, options) if err != nil { return AlertsClientGetHistoryResponse{}, err } @@ -307,12 +356,9 @@ func (client *AlertsClient) GetHistory(ctx context.Context, alertID string, opti } // getHistoryCreateRequest creates the GetHistory request. -func (client *AlertsClient) getHistoryCreateRequest(ctx context.Context, alertID string, options *AlertsClientGetHistoryOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/alerts/{alertId}/history" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) +func (client *AlertsClient) getHistoryCreateRequest(ctx context.Context, scope string, alertID string, options *AlertsClientGetHistoryOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.AlertsManagement/alerts/{alertId}/history" + urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) if alertID == "" { return nil, errors.New("parameter alertID cannot be empty") } @@ -322,7 +368,7 @@ func (client *AlertsClient) getHistoryCreateRequest(ctx context.Context, alertID return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2019-05-05-preview") + reqQP.Set("api-version", "2023-07-12-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -341,17 +387,18 @@ func (client *AlertsClient) getHistoryHandleResponse(resp *http.Response) (Alert // count of alerts for each severity). // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2019-05-05-preview +// Generated from API version 2023-07-12-preview +// - scope - scope here is resourceId for which alert is created. // - groupby - This parameter allows the result set to be grouped by input fields (Maximum 2 comma separated fields supported). // For example, groupby=severity or groupby=severity,alertstate. // - options - AlertsClientGetSummaryOptions contains the optional parameters for the AlertsClient.GetSummary method. -func (client *AlertsClient) GetSummary(ctx context.Context, groupby AlertsSummaryGroupByFields, options *AlertsClientGetSummaryOptions) (AlertsClientGetSummaryResponse, error) { +func (client *AlertsClient) GetSummary(ctx context.Context, scope string, groupby AlertsSummaryGroupByFields, options *AlertsClientGetSummaryOptions) (AlertsClientGetSummaryResponse, error) { var err error const operationName = "AlertsClient.GetSummary" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.getSummaryCreateRequest(ctx, groupby, options) + req, err := client.getSummaryCreateRequest(ctx, scope, groupby, options) if err != nil { return AlertsClientGetSummaryResponse{}, err } @@ -368,12 +415,9 @@ func (client *AlertsClient) GetSummary(ctx context.Context, groupby AlertsSummar } // getSummaryCreateRequest creates the GetSummary request. -func (client *AlertsClient) getSummaryCreateRequest(ctx context.Context, groupby AlertsSummaryGroupByFields, options *AlertsClientGetSummaryOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/alertsSummary" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) +func (client *AlertsClient) getSummaryCreateRequest(ctx context.Context, scope string, groupby AlertsSummaryGroupByFields, options *AlertsClientGetSummaryOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.AlertsManagement/alertsSummary" + urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err @@ -413,7 +457,7 @@ func (client *AlertsClient) getSummaryCreateRequest(ctx context.Context, groupby if options != nil && options.CustomTimeRange != nil { reqQP.Set("customTimeRange", *options.CustomTimeRange) } - reqQP.Set("api-version", "2019-05-05-preview") + reqQP.Set("api-version", "2023-07-12-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -428,10 +472,69 @@ func (client *AlertsClient) getSummaryHandleResponse(resp *http.Response) (Alert return result, nil } +// NewListEnrichmentsPager - List the enrichments of an alert. It returns a collection of one object named default. +// +// Generated from API version 2023-07-12-preview +// - scope - scope here is resourceId for which alert is created. +// - alertID - Unique ID of an alert instance. +// - options - AlertsClientListEnrichmentsOptions contains the optional parameters for the AlertsClient.NewListEnrichmentsPager +// method. +func (client *AlertsClient) NewListEnrichmentsPager(scope string, alertID string, options *AlertsClientListEnrichmentsOptions) *runtime.Pager[AlertsClientListEnrichmentsResponse] { + return runtime.NewPager(runtime.PagingHandler[AlertsClientListEnrichmentsResponse]{ + More: func(page AlertsClientListEnrichmentsResponse) bool { + return false + }, + Fetcher: func(ctx context.Context, page *AlertsClientListEnrichmentsResponse) (AlertsClientListEnrichmentsResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "AlertsClient.NewListEnrichmentsPager") + req, err := client.listEnrichmentsCreateRequest(ctx, scope, alertID, options) + if err != nil { + return AlertsClientListEnrichmentsResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return AlertsClientListEnrichmentsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AlertsClientListEnrichmentsResponse{}, runtime.NewResponseError(resp) + } + return client.listEnrichmentsHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listEnrichmentsCreateRequest creates the ListEnrichments request. +func (client *AlertsClient) listEnrichmentsCreateRequest(ctx context.Context, scope string, alertID string, options *AlertsClientListEnrichmentsOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.AlertsManagement/alerts/{alertId}/enrichments" + urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) + if alertID == "" { + return nil, errors.New("parameter alertID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{alertId}", url.PathEscape(alertID)) + 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-07-12-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listEnrichmentsHandleResponse handles the ListEnrichments response. +func (client *AlertsClient) listEnrichmentsHandleResponse(resp *http.Response) (AlertsClientListEnrichmentsResponse, error) { + result := AlertsClientListEnrichmentsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AlertEnrichmentsList); err != nil { + return AlertsClientListEnrichmentsResponse{}, err + } + return result, nil +} + // MetaData - List alerts meta data information based on value of identifier parameter. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2019-05-05-preview +// Generated from API version 2023-07-12-preview // - identifier - Identification of the information to be retrieved by API call. // - options - AlertsClientMetaDataOptions contains the optional parameters for the AlertsClient.MetaData method. func (client *AlertsClient) MetaData(ctx context.Context, identifier Identifier, options *AlertsClientMetaDataOptions) (AlertsClientMetaDataResponse, error) { @@ -464,7 +567,7 @@ func (client *AlertsClient) metaDataCreateRequest(ctx context.Context, identifie return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2019-05-05-preview") + reqQP.Set("api-version", "2023-07-12-preview") reqQP.Set("identifier", string(identifier)) req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} 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 e4581f121c4c..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:02.000Z"); 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:02.000Z"); 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:02.000Z"); 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:02.000Z"); 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:02.000Z"); 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:02.000Z"); 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:02.000Z"); 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:02.000Z"); 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:02.000Z"); 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:02.000Z"); 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:02.000Z"); 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:02.000Z"); 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 7d42c93b5f02..bb9a4a7c56b3 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.9.0 +module-version: 0.10.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 8cd4f2c0e855..a6edba7ce0c5 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/client_factory.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/client_factory.go @@ -43,9 +43,15 @@ func (c *ClientFactory) NewAlertProcessingRulesClient() *AlertProcessingRulesCli return subClient } +// NewAlertRuleRecommendationsClient creates a new instance of AlertRuleRecommendationsClient. +func (c *ClientFactory) NewAlertRuleRecommendationsClient() *AlertRuleRecommendationsClient { + subClient, _ := NewAlertRuleRecommendationsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + // NewAlertsClient creates a new instance of AlertsClient. func (c *ClientFactory) NewAlertsClient() *AlertsClient { - subClient, _ := NewAlertsClient(c.subscriptionID, c.credential, c.options) + subClient, _ := NewAlertsClient(c.credential, c.options) return subClient } @@ -55,6 +61,12 @@ func (c *ClientFactory) NewOperationsClient() *OperationsClient { return subClient } +// NewPrometheusRuleGroupsClient creates a new instance of PrometheusRuleGroupsClient. +func (c *ClientFactory) NewPrometheusRuleGroupsClient() *PrometheusRuleGroupsClient { + subClient, _ := NewPrometheusRuleGroupsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + // NewSmartGroupsClient creates a new instance of SmartGroupsClient. func (c *ClientFactory) NewSmartGroupsClient() *SmartGroupsClient { subClient, _ := NewSmartGroupsClient(c.subscriptionID, c.credential, c.options) diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/constants.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/constants.go index db90b267bcc7..b6796f026d95 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/constants.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/constants.go @@ -10,7 +10,7 @@ package armalertsmanagement const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/alertsmanagement/armalertsmanagement" - moduleVersion = "v0.9.0" + moduleVersion = "v0.10.0" ) // ActionType - Action that should be applied. @@ -18,6 +18,7 @@ type ActionType string const ( ActionTypeAddActionGroups ActionType = "AddActionGroups" + ActionTypeCorrelateAlerts ActionType = "CorrelateAlerts" ActionTypeRemoveAllActionGroups ActionType = "RemoveAllActionGroups" ) @@ -25,6 +26,7 @@ const ( func PossibleActionTypeValues() []ActionType { return []ActionType{ ActionTypeAddActionGroups, + ActionTypeCorrelateAlerts, ActionTypeRemoveAllActionGroups, } } @@ -237,6 +239,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 ( @@ -264,6 +350,7 @@ const ( MonitorServiceLogAnalytics MonitorService = "Log Analytics" MonitorServiceNagios MonitorService = "Nagios" MonitorServicePlatform MonitorService = "Platform" + MonitorServiceResourceHealth MonitorService = "Resource Health" MonitorServiceSCOM MonitorService = "SCOM" MonitorServiceServiceHealth MonitorService = "ServiceHealth" MonitorServiceSmartDetector MonitorService = "SmartDetector" @@ -283,6 +370,7 @@ func PossibleMonitorServiceValues() []MonitorService { MonitorServiceLogAnalytics, MonitorServiceNagios, MonitorServicePlatform, + MonitorServiceResourceHealth, MonitorServiceSCOM, MonitorServiceServiceHealth, MonitorServiceSmartDetector, @@ -291,6 +379,22 @@ func PossibleMonitorServiceValues() []MonitorService { } } +// NotificationsForCorrelatedAlerts - Indicates how to handle child alerts notifications. +type NotificationsForCorrelatedAlerts string + +const ( + NotificationsForCorrelatedAlertsNotifyAlways NotificationsForCorrelatedAlerts = "NotifyAlways" + NotificationsForCorrelatedAlertsSuppressAlways NotificationsForCorrelatedAlerts = "SuppressAlways" +) + +// PossibleNotificationsForCorrelatedAlertsValues returns the possible values for the NotificationsForCorrelatedAlerts const type. +func PossibleNotificationsForCorrelatedAlertsValues() []NotificationsForCorrelatedAlerts { + return []NotificationsForCorrelatedAlerts{ + NotificationsForCorrelatedAlertsNotifyAlways, + NotificationsForCorrelatedAlertsSuppressAlways, + } +} + // Operator - Operator for a given condition. type Operator string @@ -442,6 +546,22 @@ func PossibleStateValues() []State { } } +// Status - The status of the evaluation of the enrichment. +type Status string + +const ( + StatusFailed Status = "Failed" + StatusSucceeded Status = "Succeeded" +) + +// PossibleStatusValues returns the possible values for the Status const type. +func PossibleStatusValues() []Status { + return []Status{ + StatusFailed, + StatusSucceeded, + } +} + type TimeRange string const ( @@ -460,3 +580,19 @@ func PossibleTimeRangeValues() []TimeRange { TimeRangeThirtyD, } } + +// Type - The enrichment type. +type Type string + +const ( + TypePrometheusInstantQuery Type = "PrometheusInstantQuery" + TypePrometheusRangeQuery Type = "PrometheusRangeQuery" +) + +// PossibleTypeValues returns the possible values for the Type const type. +func PossibleTypeValues() []Type { + return []Type{ + TypePrometheusInstantQuery, + TypePrometheusRangeQuery, + } +} diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/alertrulerecommendations_server.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/alertrulerecommendations_server.go new file mode 100644 index 000000000000..eabf2dfcfc7e --- /dev/null +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/alertrulerecommendations_server.go @@ -0,0 +1,154 @@ +//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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/alertsmanagement/armalertsmanagement" + "net/http" + "net/url" + "regexp" +) + +// AlertRuleRecommendationsServer is a fake server for instances of the armalertsmanagement.AlertRuleRecommendationsClient type. +type AlertRuleRecommendationsServer struct { + // NewListByResourcePager is the fake for method AlertRuleRecommendationsClient.NewListByResourcePager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourcePager func(resourceURI string, options *armalertsmanagement.AlertRuleRecommendationsClientListByResourceOptions) (resp azfake.PagerResponder[armalertsmanagement.AlertRuleRecommendationsClientListByResourceResponse]) + + // NewListByTargetTypePager is the fake for method AlertRuleRecommendationsClient.NewListByTargetTypePager + // HTTP status codes to indicate success: http.StatusOK + NewListByTargetTypePager func(targetType string, options *armalertsmanagement.AlertRuleRecommendationsClientListByTargetTypeOptions) (resp azfake.PagerResponder[armalertsmanagement.AlertRuleRecommendationsClientListByTargetTypeResponse]) +} + +// NewAlertRuleRecommendationsServerTransport creates a new instance of AlertRuleRecommendationsServerTransport with the provided implementation. +// The returned AlertRuleRecommendationsServerTransport instance is connected to an instance of armalertsmanagement.AlertRuleRecommendationsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewAlertRuleRecommendationsServerTransport(srv *AlertRuleRecommendationsServer) *AlertRuleRecommendationsServerTransport { + return &AlertRuleRecommendationsServerTransport{ + srv: srv, + newListByResourcePager: newTracker[azfake.PagerResponder[armalertsmanagement.AlertRuleRecommendationsClientListByResourceResponse]](), + newListByTargetTypePager: newTracker[azfake.PagerResponder[armalertsmanagement.AlertRuleRecommendationsClientListByTargetTypeResponse]](), + } +} + +// AlertRuleRecommendationsServerTransport connects instances of armalertsmanagement.AlertRuleRecommendationsClient to instances of AlertRuleRecommendationsServer. +// Don't use this type directly, use NewAlertRuleRecommendationsServerTransport instead. +type AlertRuleRecommendationsServerTransport struct { + srv *AlertRuleRecommendationsServer + newListByResourcePager *tracker[azfake.PagerResponder[armalertsmanagement.AlertRuleRecommendationsClientListByResourceResponse]] + newListByTargetTypePager *tracker[azfake.PagerResponder[armalertsmanagement.AlertRuleRecommendationsClientListByTargetTypeResponse]] +} + +// Do implements the policy.Transporter interface for AlertRuleRecommendationsServerTransport. +func (a *AlertRuleRecommendationsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "AlertRuleRecommendationsClient.NewListByResourcePager": + resp, err = a.dispatchNewListByResourcePager(req) + case "AlertRuleRecommendationsClient.NewListByTargetTypePager": + resp, err = a.dispatchNewListByTargetTypePager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (a *AlertRuleRecommendationsServerTransport) dispatchNewListByResourcePager(req *http.Request) (*http.Response, error) { + if a.srv.NewListByResourcePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourcePager not implemented")} + } + newListByResourcePager := a.newListByResourcePager.get(req) + if newListByResourcePager == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AlertsManagement/alertRuleRecommendations` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + resp := a.srv.NewListByResourcePager(resourceURIParam, nil) + newListByResourcePager = &resp + a.newListByResourcePager.add(req, newListByResourcePager) + server.PagerResponderInjectNextLinks(newListByResourcePager, req, func(page *armalertsmanagement.AlertRuleRecommendationsClientListByResourceResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByResourcePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + a.newListByResourcePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourcePager) { + a.newListByResourcePager.remove(req) + } + return resp, nil +} + +func (a *AlertRuleRecommendationsServerTransport) dispatchNewListByTargetTypePager(req *http.Request) (*http.Response, error) { + if a.srv.NewListByTargetTypePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByTargetTypePager not implemented")} + } + newListByTargetTypePager := a.newListByTargetTypePager.get(req) + if newListByTargetTypePager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AlertsManagement/alertRuleRecommendations` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + targetTypeParam, err := url.QueryUnescape(qp.Get("targetType")) + if err != nil { + return nil, err + } + resp := a.srv.NewListByTargetTypePager(targetTypeParam, nil) + newListByTargetTypePager = &resp + a.newListByTargetTypePager.add(req, newListByTargetTypePager) + server.PagerResponderInjectNextLinks(newListByTargetTypePager, req, func(page *armalertsmanagement.AlertRuleRecommendationsClientListByTargetTypeResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByTargetTypePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + a.newListByTargetTypePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByTargetTypePager) { + a.newListByTargetTypePager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/alerts_server.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/alerts_server.go index ebdc590fdddb..46295ac78d2d 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/alerts_server.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/alerts_server.go @@ -28,23 +28,31 @@ import ( type AlertsServer struct { // ChangeState is the fake for method AlertsClient.ChangeState // HTTP status codes to indicate success: http.StatusOK - ChangeState func(ctx context.Context, alertID string, newState armalertsmanagement.AlertState, options *armalertsmanagement.AlertsClientChangeStateOptions) (resp azfake.Responder[armalertsmanagement.AlertsClientChangeStateResponse], errResp azfake.ErrorResponder) + ChangeState func(ctx context.Context, scope string, alertID string, newState armalertsmanagement.AlertState, options *armalertsmanagement.AlertsClientChangeStateOptions) (resp azfake.Responder[armalertsmanagement.AlertsClientChangeStateResponse], errResp azfake.ErrorResponder) // NewGetAllPager is the fake for method AlertsClient.NewGetAllPager // HTTP status codes to indicate success: http.StatusOK - NewGetAllPager func(options *armalertsmanagement.AlertsClientGetAllOptions) (resp azfake.PagerResponder[armalertsmanagement.AlertsClientGetAllResponse]) + NewGetAllPager func(scope string, options *armalertsmanagement.AlertsClientGetAllOptions) (resp azfake.PagerResponder[armalertsmanagement.AlertsClientGetAllResponse]) // GetByID is the fake for method AlertsClient.GetByID // HTTP status codes to indicate success: http.StatusOK - GetByID func(ctx context.Context, alertID string, options *armalertsmanagement.AlertsClientGetByIDOptions) (resp azfake.Responder[armalertsmanagement.AlertsClientGetByIDResponse], errResp azfake.ErrorResponder) + GetByID func(ctx context.Context, scope string, alertID string, options *armalertsmanagement.AlertsClientGetByIDOptions) (resp azfake.Responder[armalertsmanagement.AlertsClientGetByIDResponse], errResp azfake.ErrorResponder) + + // GetEnrichments is the fake for method AlertsClient.GetEnrichments + // HTTP status codes to indicate success: http.StatusOK + GetEnrichments func(ctx context.Context, scope string, alertID string, options *armalertsmanagement.AlertsClientGetEnrichmentsOptions) (resp azfake.Responder[armalertsmanagement.AlertsClientGetEnrichmentsResponse], errResp azfake.ErrorResponder) // GetHistory is the fake for method AlertsClient.GetHistory // HTTP status codes to indicate success: http.StatusOK - GetHistory func(ctx context.Context, alertID string, options *armalertsmanagement.AlertsClientGetHistoryOptions) (resp azfake.Responder[armalertsmanagement.AlertsClientGetHistoryResponse], errResp azfake.ErrorResponder) + GetHistory func(ctx context.Context, scope string, alertID string, options *armalertsmanagement.AlertsClientGetHistoryOptions) (resp azfake.Responder[armalertsmanagement.AlertsClientGetHistoryResponse], errResp azfake.ErrorResponder) // GetSummary is the fake for method AlertsClient.GetSummary // HTTP status codes to indicate success: http.StatusOK - GetSummary func(ctx context.Context, groupby armalertsmanagement.AlertsSummaryGroupByFields, options *armalertsmanagement.AlertsClientGetSummaryOptions) (resp azfake.Responder[armalertsmanagement.AlertsClientGetSummaryResponse], errResp azfake.ErrorResponder) + GetSummary func(ctx context.Context, scope string, groupby armalertsmanagement.AlertsSummaryGroupByFields, options *armalertsmanagement.AlertsClientGetSummaryOptions) (resp azfake.Responder[armalertsmanagement.AlertsClientGetSummaryResponse], errResp azfake.ErrorResponder) + + // NewListEnrichmentsPager is the fake for method AlertsClient.NewListEnrichmentsPager + // HTTP status codes to indicate success: http.StatusOK + NewListEnrichmentsPager func(scope string, alertID string, options *armalertsmanagement.AlertsClientListEnrichmentsOptions) (resp azfake.PagerResponder[armalertsmanagement.AlertsClientListEnrichmentsResponse]) // MetaData is the fake for method AlertsClient.MetaData // HTTP status codes to indicate success: http.StatusOK @@ -56,16 +64,18 @@ type AlertsServer struct { // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewAlertsServerTransport(srv *AlertsServer) *AlertsServerTransport { return &AlertsServerTransport{ - srv: srv, - newGetAllPager: newTracker[azfake.PagerResponder[armalertsmanagement.AlertsClientGetAllResponse]](), + srv: srv, + newGetAllPager: newTracker[azfake.PagerResponder[armalertsmanagement.AlertsClientGetAllResponse]](), + newListEnrichmentsPager: newTracker[azfake.PagerResponder[armalertsmanagement.AlertsClientListEnrichmentsResponse]](), } } // AlertsServerTransport connects instances of armalertsmanagement.AlertsClient to instances of AlertsServer. // Don't use this type directly, use NewAlertsServerTransport instead. type AlertsServerTransport struct { - srv *AlertsServer - newGetAllPager *tracker[azfake.PagerResponder[armalertsmanagement.AlertsClientGetAllResponse]] + srv *AlertsServer + newGetAllPager *tracker[azfake.PagerResponder[armalertsmanagement.AlertsClientGetAllResponse]] + newListEnrichmentsPager *tracker[azfake.PagerResponder[armalertsmanagement.AlertsClientListEnrichmentsResponse]] } // Do implements the policy.Transporter interface for AlertsServerTransport. @@ -86,10 +96,14 @@ func (a *AlertsServerTransport) Do(req *http.Request) (*http.Response, error) { resp, err = a.dispatchNewGetAllPager(req) case "AlertsClient.GetByID": resp, err = a.dispatchGetByID(req) + case "AlertsClient.GetEnrichments": + resp, err = a.dispatchGetEnrichments(req) case "AlertsClient.GetHistory": resp, err = a.dispatchGetHistory(req) case "AlertsClient.GetSummary": resp, err = a.dispatchGetSummary(req) + case "AlertsClient.NewListEnrichmentsPager": + resp, err = a.dispatchNewListEnrichmentsPager(req) case "AlertsClient.MetaData": resp, err = a.dispatchMetaData(req) default: @@ -107,14 +121,18 @@ func (a *AlertsServerTransport) dispatchChangeState(req *http.Request) (*http.Re if a.srv.ChangeState == nil { return nil, &nonRetriableError{errors.New("fake for method ChangeState not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AlertsManagement/alerts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/changestate` + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AlertsManagement/alerts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/changestate` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() - body, err := server.UnmarshalRequestAsJSON[string](req) + body, err := server.UnmarshalRequestAsJSON[armalertsmanagement.Comments](req) + if err != nil { + return nil, err + } + scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) if err != nil { return nil, err } @@ -138,7 +156,7 @@ func (a *AlertsServerTransport) dispatchChangeState(req *http.Request) (*http.Re Comment: &body, } } - respr, errRespr := a.srv.ChangeState(req.Context(), alertIDParam, newStateParam, options) + respr, errRespr := a.srv.ChangeState(req.Context(), scopeParam, alertIDParam, newStateParam, options) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -159,13 +177,17 @@ func (a *AlertsServerTransport) dispatchNewGetAllPager(req *http.Request) (*http } newGetAllPager := a.newGetAllPager.get(req) if newGetAllPager == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AlertsManagement/alerts` + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AlertsManagement/alerts` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 1 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() + scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) + if err != nil { + return nil, err + } targetResourceUnescaped, err := url.QueryUnescape(qp.Get("targetResource")) if err != nil { return nil, err @@ -288,7 +310,7 @@ func (a *AlertsServerTransport) dispatchNewGetAllPager(req *http.Request) (*http CustomTimeRange: customTimeRangeParam, } } - resp := a.srv.NewGetAllPager(options) + resp := a.srv.NewGetAllPager(scopeParam, options) newGetAllPager = &resp a.newGetAllPager.add(req, newGetAllPager) server.PagerResponderInjectNextLinks(newGetAllPager, req, func(page *armalertsmanagement.AlertsClientGetAllResponse, createLink func() string) { @@ -313,17 +335,21 @@ func (a *AlertsServerTransport) dispatchGetByID(req *http.Request) (*http.Respon if a.srv.GetByID == nil { return nil, &nonRetriableError{errors.New("fake for method GetByID not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AlertsManagement/alerts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AlertsManagement/alerts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } + scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) + if err != nil { + return nil, err + } alertIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("alertId")]) if err != nil { return nil, err } - respr, errRespr := a.srv.GetByID(req.Context(), alertIDParam, nil) + respr, errRespr := a.srv.GetByID(req.Context(), scopeParam, alertIDParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -338,21 +364,58 @@ func (a *AlertsServerTransport) dispatchGetByID(req *http.Request) (*http.Respon return resp, nil } +func (a *AlertsServerTransport) dispatchGetEnrichments(req *http.Request) (*http.Response, error) { + if a.srv.GetEnrichments == nil { + return nil, &nonRetriableError{errors.New("fake for method GetEnrichments not implemented")} + } + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AlertsManagement/alerts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/enrichments/default` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) + if err != nil { + return nil, err + } + alertIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("alertId")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.GetEnrichments(req.Context(), scopeParam, alertIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).AlertEnrichmentResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + func (a *AlertsServerTransport) dispatchGetHistory(req *http.Request) (*http.Response, error) { if a.srv.GetHistory == nil { return nil, &nonRetriableError{errors.New("fake for method GetHistory not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AlertsManagement/alerts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/history` + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AlertsManagement/alerts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/history` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } + scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) + if err != nil { + return nil, err + } alertIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("alertId")]) if err != nil { return nil, err } - respr, errRespr := a.srv.GetHistory(req.Context(), alertIDParam, nil) + respr, errRespr := a.srv.GetHistory(req.Context(), scopeParam, alertIDParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -371,13 +434,17 @@ func (a *AlertsServerTransport) dispatchGetSummary(req *http.Request) (*http.Res if a.srv.GetSummary == nil { return nil, &nonRetriableError{errors.New("fake for method GetSummary not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AlertsManagement/alertsSummary` + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AlertsManagement/alertsSummary` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 1 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() + scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) + if err != nil { + return nil, err + } groupbyParam, err := parseWithCast(qp.Get("groupby"), func(v string) (armalertsmanagement.AlertsSummaryGroupByFields, error) { p, unescapeErr := url.QueryUnescape(v) if unescapeErr != nil { @@ -462,7 +529,7 @@ func (a *AlertsServerTransport) dispatchGetSummary(req *http.Request) (*http.Res CustomTimeRange: customTimeRangeParam, } } - respr, errRespr := a.srv.GetSummary(req.Context(), groupbyParam, options) + respr, errRespr := a.srv.GetSummary(req.Context(), scopeParam, groupbyParam, options) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -477,6 +544,44 @@ func (a *AlertsServerTransport) dispatchGetSummary(req *http.Request) (*http.Res return resp, nil } +func (a *AlertsServerTransport) dispatchNewListEnrichmentsPager(req *http.Request) (*http.Response, error) { + if a.srv.NewListEnrichmentsPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListEnrichmentsPager not implemented")} + } + newListEnrichmentsPager := a.newListEnrichmentsPager.get(req) + if newListEnrichmentsPager == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AlertsManagement/alerts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/enrichments` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) + if err != nil { + return nil, err + } + alertIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("alertId")]) + if err != nil { + return nil, err + } + resp := a.srv.NewListEnrichmentsPager(scopeParam, alertIDParam, nil) + newListEnrichmentsPager = &resp + a.newListEnrichmentsPager.add(req, newListEnrichmentsPager) + } + resp, err := server.PagerResponderNext(newListEnrichmentsPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + a.newListEnrichmentsPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListEnrichmentsPager) { + a.newListEnrichmentsPager.remove(req) + } + return resp, nil +} + func (a *AlertsServerTransport) dispatchMetaData(req *http.Request) (*http.Response, error) { if a.srv.MetaData == nil { return nil, &nonRetriableError{errors.New("fake for method MetaData not implemented")} diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/prometheusrulegroups_server.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/prometheusrulegroups_server.go new file mode 100644 index 000000000000..2ba7f0982fe5 --- /dev/null +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/prometheusrulegroups_server.go @@ -0,0 +1,307 @@ +//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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/alertsmanagement/armalertsmanagement" + "net/http" + "net/url" + "regexp" +) + +// PrometheusRuleGroupsServer is a fake server for instances of the armalertsmanagement.PrometheusRuleGroupsClient type. +type PrometheusRuleGroupsServer struct { + // CreateOrUpdate is the fake for method PrometheusRuleGroupsClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, ruleGroupName string, parameters armalertsmanagement.PrometheusRuleGroupResource, options *armalertsmanagement.PrometheusRuleGroupsClientCreateOrUpdateOptions) (resp azfake.Responder[armalertsmanagement.PrometheusRuleGroupsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method PrometheusRuleGroupsClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, ruleGroupName string, options *armalertsmanagement.PrometheusRuleGroupsClientDeleteOptions) (resp azfake.Responder[armalertsmanagement.PrometheusRuleGroupsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method PrometheusRuleGroupsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, ruleGroupName string, options *armalertsmanagement.PrometheusRuleGroupsClientGetOptions) (resp azfake.Responder[armalertsmanagement.PrometheusRuleGroupsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByResourceGroupPager is the fake for method PrometheusRuleGroupsClient.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *armalertsmanagement.PrometheusRuleGroupsClientListByResourceGroupOptions) (resp azfake.PagerResponder[armalertsmanagement.PrometheusRuleGroupsClientListByResourceGroupResponse]) + + // NewListBySubscriptionPager is the fake for method PrometheusRuleGroupsClient.NewListBySubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewListBySubscriptionPager func(options *armalertsmanagement.PrometheusRuleGroupsClientListBySubscriptionOptions) (resp azfake.PagerResponder[armalertsmanagement.PrometheusRuleGroupsClientListBySubscriptionResponse]) + + // Update is the fake for method PrometheusRuleGroupsClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, ruleGroupName string, parameters armalertsmanagement.PrometheusRuleGroupResourcePatchParameters, options *armalertsmanagement.PrometheusRuleGroupsClientUpdateOptions) (resp azfake.Responder[armalertsmanagement.PrometheusRuleGroupsClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewPrometheusRuleGroupsServerTransport creates a new instance of PrometheusRuleGroupsServerTransport with the provided implementation. +// The returned PrometheusRuleGroupsServerTransport instance is connected to an instance of armalertsmanagement.PrometheusRuleGroupsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewPrometheusRuleGroupsServerTransport(srv *PrometheusRuleGroupsServer) *PrometheusRuleGroupsServerTransport { + return &PrometheusRuleGroupsServerTransport{ + srv: srv, + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armalertsmanagement.PrometheusRuleGroupsClientListByResourceGroupResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[armalertsmanagement.PrometheusRuleGroupsClientListBySubscriptionResponse]](), + } +} + +// PrometheusRuleGroupsServerTransport connects instances of armalertsmanagement.PrometheusRuleGroupsClient to instances of PrometheusRuleGroupsServer. +// Don't use this type directly, use NewPrometheusRuleGroupsServerTransport instead. +type PrometheusRuleGroupsServerTransport struct { + srv *PrometheusRuleGroupsServer + newListByResourceGroupPager *tracker[azfake.PagerResponder[armalertsmanagement.PrometheusRuleGroupsClientListByResourceGroupResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[armalertsmanagement.PrometheusRuleGroupsClientListBySubscriptionResponse]] +} + +// Do implements the policy.Transporter interface for PrometheusRuleGroupsServerTransport. +func (p *PrometheusRuleGroupsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "PrometheusRuleGroupsClient.CreateOrUpdate": + resp, err = p.dispatchCreateOrUpdate(req) + case "PrometheusRuleGroupsClient.Delete": + resp, err = p.dispatchDelete(req) + case "PrometheusRuleGroupsClient.Get": + resp, err = p.dispatchGet(req) + case "PrometheusRuleGroupsClient.NewListByResourceGroupPager": + resp, err = p.dispatchNewListByResourceGroupPager(req) + case "PrometheusRuleGroupsClient.NewListBySubscriptionPager": + resp, err = p.dispatchNewListBySubscriptionPager(req) + case "PrometheusRuleGroupsClient.Update": + resp, err = p.dispatchUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (p *PrometheusRuleGroupsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if p.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AlertsManagement/prometheusRuleGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armalertsmanagement.PrometheusRuleGroupResource](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + ruleGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("ruleGroupName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, ruleGroupNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).PrometheusRuleGroupResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (p *PrometheusRuleGroupsServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if p.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AlertsManagement/prometheusRuleGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + ruleGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("ruleGroupName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.Delete(req.Context(), resourceGroupNameParam, ruleGroupNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (p *PrometheusRuleGroupsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if p.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AlertsManagement/prometheusRuleGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + ruleGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("ruleGroupName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.Get(req.Context(), resourceGroupNameParam, ruleGroupNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).PrometheusRuleGroupResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (p *PrometheusRuleGroupsServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if p.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} + } + newListByResourceGroupPager := p.newListByResourceGroupPager.get(req) + if newListByResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AlertsManagement/prometheusRuleGroups` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resp := p.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil) + newListByResourceGroupPager = &resp + p.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + } + resp, err := server.PagerResponderNext(newListByResourceGroupPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + p.newListByResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourceGroupPager) { + p.newListByResourceGroupPager.remove(req) + } + return resp, nil +} + +func (p *PrometheusRuleGroupsServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) { + if p.srv.NewListBySubscriptionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")} + } + newListBySubscriptionPager := p.newListBySubscriptionPager.get(req) + if newListBySubscriptionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AlertsManagement/prometheusRuleGroups` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := p.srv.NewListBySubscriptionPager(nil) + newListBySubscriptionPager = &resp + p.newListBySubscriptionPager.add(req, newListBySubscriptionPager) + } + resp, err := server.PagerResponderNext(newListBySubscriptionPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + p.newListBySubscriptionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBySubscriptionPager) { + p.newListBySubscriptionPager.remove(req) + } + return resp, nil +} + +func (p *PrometheusRuleGroupsServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if p.srv.Update == nil { + return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AlertsManagement/prometheusRuleGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armalertsmanagement.PrometheusRuleGroupResourcePatchParameters](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + ruleGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("ruleGroupName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.Update(req.Context(), resourceGroupNameParam, ruleGroupNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).PrometheusRuleGroupResource, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/server_factory.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/server_factory.go index f319773b0517..3d3ac0c9325d 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/server_factory.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/server_factory.go @@ -19,10 +19,12 @@ import ( // ServerFactory is a fake server for instances of the armalertsmanagement.ClientFactory type. type ServerFactory struct { - AlertProcessingRulesServer AlertProcessingRulesServer - AlertsServer AlertsServer - OperationsServer OperationsServer - SmartGroupsServer SmartGroupsServer + AlertProcessingRulesServer AlertProcessingRulesServer + AlertRuleRecommendationsServer AlertRuleRecommendationsServer + AlertsServer AlertsServer + OperationsServer OperationsServer + PrometheusRuleGroupsServer PrometheusRuleGroupsServer + SmartGroupsServer SmartGroupsServer } // NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. @@ -37,12 +39,14 @@ func NewServerFactoryTransport(srv *ServerFactory) *ServerFactoryTransport { // ServerFactoryTransport connects instances of armalertsmanagement.ClientFactory to instances of ServerFactory. // Don't use this type directly, use NewServerFactoryTransport instead. type ServerFactoryTransport struct { - srv *ServerFactory - trMu sync.Mutex - trAlertProcessingRulesServer *AlertProcessingRulesServerTransport - trAlertsServer *AlertsServerTransport - trOperationsServer *OperationsServerTransport - trSmartGroupsServer *SmartGroupsServerTransport + srv *ServerFactory + trMu sync.Mutex + trAlertProcessingRulesServer *AlertProcessingRulesServerTransport + trAlertRuleRecommendationsServer *AlertRuleRecommendationsServerTransport + trAlertsServer *AlertsServerTransport + trOperationsServer *OperationsServerTransport + trPrometheusRuleGroupsServer *PrometheusRuleGroupsServerTransport + trSmartGroupsServer *SmartGroupsServerTransport } // Do implements the policy.Transporter interface for ServerFactoryTransport. @@ -63,12 +67,22 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { return NewAlertProcessingRulesServerTransport(&s.srv.AlertProcessingRulesServer) }) resp, err = s.trAlertProcessingRulesServer.Do(req) + case "AlertRuleRecommendationsClient": + initServer(s, &s.trAlertRuleRecommendationsServer, func() *AlertRuleRecommendationsServerTransport { + return NewAlertRuleRecommendationsServerTransport(&s.srv.AlertRuleRecommendationsServer) + }) + resp, err = s.trAlertRuleRecommendationsServer.Do(req) case "AlertsClient": initServer(s, &s.trAlertsServer, func() *AlertsServerTransport { return NewAlertsServerTransport(&s.srv.AlertsServer) }) resp, err = s.trAlertsServer.Do(req) case "OperationsClient": initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) resp, err = s.trOperationsServer.Do(req) + case "PrometheusRuleGroupsClient": + initServer(s, &s.trPrometheusRuleGroupsServer, func() *PrometheusRuleGroupsServerTransport { + return NewPrometheusRuleGroupsServerTransport(&s.srv.PrometheusRuleGroupsServer) + }) + resp, err = s.trPrometheusRuleGroupsServer.Do(req) case "SmartGroupsClient": initServer(s, &s.trSmartGroupsServer, func() *SmartGroupsServerTransport { return NewSmartGroupsServerTransport(&s.srv.SmartGroupsServer) }) resp, err = s.trSmartGroupsServer.Do(req) diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/go.mod b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/go.mod index 8cd2a7bc0a3a..6a201013f678 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/go.mod +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/go.mod @@ -4,13 +4,13 @@ go 1.18 require ( github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2 v2.0.0 github.com/stretchr/testify v1.8.4 ) require ( + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 // indirect github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.1.1 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/interfaces.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/interfaces.go index dca29e7719d2..c4b2b9c4abd6 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/interfaces.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/interfaces.go @@ -11,12 +11,21 @@ package armalertsmanagement // ActionClassification provides polymorphic access to related types. // Call the interface's GetAction() method to access the common type. // Use a type switch to determine the concrete type. The possible types are: -// - *Action, *AddActionGroups, *RemoveAllActionGroups +// - *Action, *AddActionGroups, *CorrelateAlerts, *RemoveAllActionGroups type ActionClassification interface { // GetAction returns the Action content of the underlying type. GetAction() *Action } +// AlertEnrichmentItemClassification provides polymorphic access to related types. +// Call the interface's GetAlertEnrichmentItem() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *AlertEnrichmentItem, *PrometheusEnrichmentItem, *PrometheusInstantQuery, *PrometheusRangeQuery +type AlertEnrichmentItemClassification interface { + // GetAlertEnrichmentItem returns the AlertEnrichmentItem content of the underlying type. + GetAlertEnrichmentItem() *AlertEnrichmentItem +} + // AlertsMetaDataPropertiesClassification provides polymorphic access to related types. // Call the interface's GetAlertsMetaDataProperties() method to access the common type. // Use a type switch to determine the concrete type. The possible types are: @@ -26,6 +35,16 @@ type AlertsMetaDataPropertiesClassification interface { GetAlertsMetaDataProperties() *AlertsMetaDataProperties } +// PrometheusEnrichmentItemClassification provides polymorphic access to related types. +// Call the interface's GetPrometheusEnrichmentItem() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *PrometheusEnrichmentItem, *PrometheusInstantQuery, *PrometheusRangeQuery +type PrometheusEnrichmentItemClassification interface { + AlertEnrichmentItemClassification + // GetPrometheusEnrichmentItem returns the PrometheusEnrichmentItem content of the underlying type. + GetPrometheusEnrichmentItem() *PrometheusEnrichmentItem +} + // 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: diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/models.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/models.go index d5465d8b480a..24f403ef13bb 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/models.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/models.go @@ -56,6 +56,63 @@ type Alert struct { Type *string } +// AlertEnrichmentItem - Alert enrichment item. +type AlertEnrichmentItem struct { + // REQUIRED; The enrichment description. + Description *string + + // REQUIRED; The status of the evaluation of the enrichment. + Status *Status + + // REQUIRED; The enrichment title. + Title *string + + // REQUIRED; The enrichment type. + Type *Type + + // The error message. Will be present only if the status is 'Failed'. + ErrorMessage *string +} + +// GetAlertEnrichmentItem implements the AlertEnrichmentItemClassification interface for type AlertEnrichmentItem. +func (a *AlertEnrichmentItem) GetAlertEnrichmentItem() *AlertEnrichmentItem { return a } + +// AlertEnrichmentProperties - Properties of the alert enrichment item. +type AlertEnrichmentProperties struct { + // Enrichment details + Enrichments []AlertEnrichmentItemClassification + + // READ-ONLY; Unique Id (GUID) of the alert for which the enrichments are being retrieved. + AlertID *string +} + +// AlertEnrichmentResponse - The alert's enrichments. +type AlertEnrichmentResponse struct { + // Properties of the alert enrichment item. + Properties *AlertEnrichmentProperties + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/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 +} + +// AlertEnrichmentsList - List the alert's enrichments. +type AlertEnrichmentsList struct { + // Request URL that can be used to query next page. + NextLink *string + + // List the alert's enrichments + Value []*AlertEnrichmentResponse +} + // AlertModification - Alert Modification details type AlertModification struct { // Properties of the alert modification item. @@ -171,6 +228,48 @@ 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 + + // The recommendation alert rule category. + Category *string +} + +// 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 +} + +// 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 +} + // AlertsList - List the alerts. type AlertsList struct { // URL to fetch the next set of alerts. @@ -240,6 +339,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. @@ -252,6 +356,37 @@ type Condition struct { Values []*string } +// CorrelateAlerts - Add logic for alerts correlation. +type CorrelateAlerts struct { + // REQUIRED; Action that should be applied. + ActionType *ActionType + + // REQUIRED; The list of conditions for the alerts correlations. + CorrelateBy []*CorrelateBy + + // REQUIRED; The required duration (in ISO8601 format) for the alerts correlation. + CorrelationInterval *string + + // REQUIRED; The priority of this correlation. + Priority *int32 + + // Indicates how to handle child alerts notifications. + NotificationsForCorrelatedAlerts *NotificationsForCorrelatedAlerts +} + +// GetAction implements the ActionClassification interface for type CorrelateAlerts. +func (c *CorrelateAlerts) GetAction() *Action { + return &Action{ + ActionType: c.ActionType, + } +} + +// CorrelateBy - The logic for the correlation. +type CorrelateBy struct { + // The JPath of the property that the alerts should be correlated by. + Field *string +} + // DailyRecurrence - Daily recurrence object. type DailyRecurrence struct { // REQUIRED; Specifies when the recurrence should be applied. @@ -273,20 +408,79 @@ 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 +} + +// ErrorDetailAutoGenerated - The error detail. +type ErrorDetailAutoGenerated struct { + // READ-ONLY; The error additional info. + AdditionalInfo []*ErrorAdditionalInfo + + // READ-ONLY; The error code. + Code *string + + // READ-ONLY; The error details. + Details []*ErrorDetailAutoGenerated + + // 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. +// ErrorResponseAutoGenerated2 - 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 ErrorResponseAutoGenerated2 struct { + // The error object. + Error *ErrorDetailAutoGenerated +} + +// ErrorResponseAutoGenerated3 - An error response from the service. +type ErrorResponseAutoGenerated3 struct { + // Details of error response. + Error *ErrorResponseBodyAutoGenerated +} + +// ErrorResponseAutoGenerated4 - An error response from the service. +type ErrorResponseAutoGenerated4 struct { // Details of error response. Error *ErrorResponseBodyAutoGenerated2 } @@ -519,6 +713,311 @@ type PatchProperties struct { Enabled *bool } +// PrometheusEnrichmentItem - Prometheus enrichment object. +type PrometheusEnrichmentItem struct { + // REQUIRED; An array of the azure monitor workspace resource ids. + Datasources []*string + + // REQUIRED; The enrichment description. + Description *string + + // REQUIRED; Partial link to the Grafana explore API. + GrafanaExplorePath *string + + // REQUIRED; Link to Prometheus query API (Url format). + LinkToAPI *string + + // REQUIRED; The Prometheus expression query. + Query *string + + // REQUIRED; The status of the evaluation of the enrichment. + Status *Status + + // REQUIRED; The enrichment title. + Title *string + + // REQUIRED; The enrichment type. + Type *Type + + // The error message. Will be present only if the status is 'Failed'. + ErrorMessage *string +} + +// GetAlertEnrichmentItem implements the AlertEnrichmentItemClassification interface for type PrometheusEnrichmentItem. +func (p *PrometheusEnrichmentItem) GetAlertEnrichmentItem() *AlertEnrichmentItem { + return &AlertEnrichmentItem{ + Description: p.Description, + ErrorMessage: p.ErrorMessage, + Status: p.Status, + Title: p.Title, + Type: p.Type, + } +} + +// GetPrometheusEnrichmentItem implements the PrometheusEnrichmentItemClassification interface for type PrometheusEnrichmentItem. +func (p *PrometheusEnrichmentItem) GetPrometheusEnrichmentItem() *PrometheusEnrichmentItem { return p } + +// PrometheusInstantQuery - Prometheus instant query enrichment object. +type PrometheusInstantQuery struct { + // REQUIRED; An array of the azure monitor workspace resource ids. + Datasources []*string + + // REQUIRED; The enrichment description. + Description *string + + // REQUIRED; Partial link to the Grafana explore API. + GrafanaExplorePath *string + + // REQUIRED; Link to Prometheus query API (Url format). + LinkToAPI *string + + // REQUIRED; The Prometheus expression query. + Query *string + + // REQUIRED; The status of the evaluation of the enrichment. + Status *Status + + // REQUIRED; The date and the time of the evaluation. + Time *string + + // REQUIRED; The enrichment title. + Title *string + + // REQUIRED; The enrichment type. + Type *Type + + // The error message. Will be present only if the status is 'Failed'. + ErrorMessage *string +} + +// GetAlertEnrichmentItem implements the AlertEnrichmentItemClassification interface for type PrometheusInstantQuery. +func (p *PrometheusInstantQuery) GetAlertEnrichmentItem() *AlertEnrichmentItem { + return &AlertEnrichmentItem{ + Description: p.Description, + ErrorMessage: p.ErrorMessage, + Status: p.Status, + Title: p.Title, + Type: p.Type, + } +} + +// GetPrometheusEnrichmentItem implements the PrometheusEnrichmentItemClassification interface for type PrometheusInstantQuery. +func (p *PrometheusInstantQuery) GetPrometheusEnrichmentItem() *PrometheusEnrichmentItem { + return &PrometheusEnrichmentItem{ + Datasources: p.Datasources, + Description: p.Description, + ErrorMessage: p.ErrorMessage, + GrafanaExplorePath: p.GrafanaExplorePath, + LinkToAPI: p.LinkToAPI, + Query: p.Query, + Status: p.Status, + Title: p.Title, + Type: p.Type, + } +} + +// PrometheusRangeQuery - Prometheus instant query enrichment object. +type PrometheusRangeQuery struct { + // REQUIRED; An array of the azure monitor workspace resource ids. + Datasources []*string + + // REQUIRED; The enrichment description. + Description *string + + // REQUIRED; The end evaluation date and time in ISO8601 format. + End *time.Time + + // REQUIRED; Partial link to the Grafana explore API. + GrafanaExplorePath *string + + // REQUIRED; Link to Prometheus query API (Url format). + LinkToAPI *string + + // REQUIRED; The Prometheus expression query. + Query *string + + // REQUIRED; The start evaluation date and time in ISO8601 format. + Start *time.Time + + // REQUIRED; The status of the evaluation of the enrichment. + Status *Status + + // REQUIRED; Query resolution step width in ISO8601 format. + Step *string + + // REQUIRED; The enrichment title. + Title *string + + // REQUIRED; The enrichment type. + Type *Type + + // The error message. Will be present only if the status is 'Failed'. + ErrorMessage *string +} + +// GetAlertEnrichmentItem implements the AlertEnrichmentItemClassification interface for type PrometheusRangeQuery. +func (p *PrometheusRangeQuery) GetAlertEnrichmentItem() *AlertEnrichmentItem { + return &AlertEnrichmentItem{ + Description: p.Description, + ErrorMessage: p.ErrorMessage, + Status: p.Status, + Title: p.Title, + Type: p.Type, + } +} + +// GetPrometheusEnrichmentItem implements the PrometheusEnrichmentItemClassification interface for type PrometheusRangeQuery. +func (p *PrometheusRangeQuery) GetPrometheusEnrichmentItem() *PrometheusEnrichmentItem { + return &PrometheusEnrichmentItem{ + Datasources: p.Datasources, + Description: p.Description, + ErrorMessage: p.ErrorMessage, + GrafanaExplorePath: p.GrafanaExplorePath, + LinkToAPI: p.LinkToAPI, + Query: p.Query, + Status: p.Status, + Title: p.Title, + Type: p.Type, + } +} + +// 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 +} + +// 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 +} + // Recurrence object. type Recurrence struct { // REQUIRED; Specifies when the recurrence should be applied. @@ -547,8 +1046,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 @@ -559,6 +1073,39 @@ type Resource struct { Type *string } +// ResourceAutoGenerated2 - Common fields that are returned in the response for all Azure Resource Manager resources +type ResourceAutoGenerated2 struct { + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/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 +} + +// 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. @@ -724,6 +1271,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 6428cdef9d4b..1f3ff157ed9b 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/models_serde.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/models_serde.go @@ -139,6 +139,154 @@ func (a *Alert) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type AlertEnrichmentItem. +func (a AlertEnrichmentItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", a.Description) + populate(objectMap, "errorMessage", a.ErrorMessage) + populate(objectMap, "status", a.Status) + populate(objectMap, "title", a.Title) + objectMap["type"] = a.Type + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AlertEnrichmentItem. +func (a *AlertEnrichmentItem) 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 "description": + err = unpopulate(val, "Description", &a.Description) + delete(rawMsg, key) + case "errorMessage": + err = unpopulate(val, "ErrorMessage", &a.ErrorMessage) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &a.Status) + delete(rawMsg, key) + case "title": + err = unpopulate(val, "Title", &a.Title) + 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 AlertEnrichmentProperties. +func (a AlertEnrichmentProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "alertId", a.AlertID) + populate(objectMap, "enrichments", a.Enrichments) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AlertEnrichmentProperties. +func (a *AlertEnrichmentProperties) 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 "alertId": + err = unpopulate(val, "AlertID", &a.AlertID) + delete(rawMsg, key) + case "enrichments": + a.Enrichments, err = unmarshalAlertEnrichmentItemClassificationArray(val) + 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 AlertEnrichmentResponse. +func (a AlertEnrichmentResponse) 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 AlertEnrichmentResponse. +func (a *AlertEnrichmentResponse) 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 AlertEnrichmentsList. +func (a AlertEnrichmentsList) 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 AlertEnrichmentsList. +func (a *AlertEnrichmentsList) 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 AlertModification. func (a AlertModification) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -424,6 +572,119 @@ 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, "category", a.Category) + 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 "category": + err = unpopulate(val, "Category", &a.Category) + 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) @@ -626,6 +887,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) @@ -661,53 +949,240 @@ func (c *Condition) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type DailyRecurrence. -func (d DailyRecurrence) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type CorrelateAlerts. +func (c CorrelateAlerts) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "endTime", d.EndTime) - objectMap["recurrenceType"] = RecurrenceTypeDaily - populate(objectMap, "startTime", d.StartTime) + objectMap["actionType"] = ActionTypeCorrelateAlerts + populate(objectMap, "correlateBy", c.CorrelateBy) + populate(objectMap, "correlationInterval", c.CorrelationInterval) + populate(objectMap, "notificationsForCorrelatedAlerts", c.NotificationsForCorrelatedAlerts) + populate(objectMap, "priority", c.Priority) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type DailyRecurrence. -func (d *DailyRecurrence) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type CorrelateAlerts. +func (c *CorrelateAlerts) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) + return fmt.Errorf("unmarshalling type %T: %v", c, err) } for key, val := range rawMsg { var err error switch key { - case "endTime": - err = unpopulate(val, "EndTime", &d.EndTime) + case "actionType": + err = unpopulate(val, "ActionType", &c.ActionType) delete(rawMsg, key) - case "recurrenceType": - err = unpopulate(val, "RecurrenceType", &d.RecurrenceType) + case "correlateBy": + err = unpopulate(val, "CorrelateBy", &c.CorrelateBy) delete(rawMsg, key) - case "startTime": - err = unpopulate(val, "StartTime", &d.StartTime) + case "correlationInterval": + err = unpopulate(val, "CorrelationInterval", &c.CorrelationInterval) + delete(rawMsg, key) + case "notificationsForCorrelatedAlerts": + err = unpopulate(val, "NotificationsForCorrelatedAlerts", &c.NotificationsForCorrelatedAlerts) + delete(rawMsg, key) + case "priority": + err = unpopulate(val, "Priority", &c.Priority) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) + return fmt.Errorf("unmarshalling type %T: %v", c, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ErrorResponse. -func (e ErrorResponse) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type CorrelateBy. +func (c CorrelateBy) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "error", e.Error) + populate(objectMap, "field", c.Field) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponse. -func (e *ErrorResponse) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type CorrelateBy. +func (c *CorrelateBy) 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) + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "field": + err = unpopulate(val, "Field", &c.Field) + 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 DailyRecurrence. +func (d DailyRecurrence) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "endTime", d.EndTime) + objectMap["recurrenceType"] = RecurrenceTypeDaily + populate(objectMap, "startTime", d.StartTime) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DailyRecurrence. +func (d *DailyRecurrence) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "endTime": + err = unpopulate(val, "EndTime", &d.EndTime) + delete(rawMsg, key) + case "recurrenceType": + err = unpopulate(val, "RecurrenceType", &d.RecurrenceType) + delete(rawMsg, key) + case "startTime": + err = unpopulate(val, "StartTime", &d.StartTime) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorAdditionalInfo. +func (e ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + 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 ErrorDetailAutoGenerated. +func (e ErrorDetailAutoGenerated) 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 ErrorDetailAutoGenerated. +func (e *ErrorDetailAutoGenerated) 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) + populate(objectMap, "error", e.Error) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponse. +func (e *ErrorResponse) 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 @@ -777,6 +1252,60 @@ 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 ErrorResponseAutoGenerated4. +func (e ErrorResponseAutoGenerated4) 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 ErrorResponseAutoGenerated4. +func (e *ErrorResponseAutoGenerated4) 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) @@ -1087,171 +1616,699 @@ func (m *MonitorServiceList) UnmarshalJSON(data []byte) error { case "data": err = unpopulate(val, "Data", &m.Data) delete(rawMsg, key) - case "metadataIdentifier": - err = unpopulate(val, "MetadataIdentifier", &m.MetadataIdentifier) + case "metadataIdentifier": + err = unpopulate(val, "MetadataIdentifier", &m.MetadataIdentifier) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MonthlyRecurrence. +func (m MonthlyRecurrence) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "daysOfMonth", m.DaysOfMonth) + populate(objectMap, "endTime", m.EndTime) + objectMap["recurrenceType"] = RecurrenceTypeMonthly + populate(objectMap, "startTime", m.StartTime) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MonthlyRecurrence. +func (m *MonthlyRecurrence) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "daysOfMonth": + err = unpopulate(val, "DaysOfMonth", &m.DaysOfMonth) + delete(rawMsg, key) + case "endTime": + err = unpopulate(val, "EndTime", &m.EndTime) + delete(rawMsg, key) + case "recurrenceType": + err = unpopulate(val, "RecurrenceType", &m.RecurrenceType) + delete(rawMsg, key) + case "startTime": + err = unpopulate(val, "StartTime", &m.StartTime) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "display", o.Display) + populate(objectMap, "name", o.Name) + populate(objectMap, "origin", o.Origin) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "origin": + err = unpopulate(val, "Origin", &o.Origin) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", o.Description) + populate(objectMap, "operation", o.Operation) + populate(objectMap, "provider", o.Provider) + populate(objectMap, "resource", o.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay. +func (o *OperationDisplay) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &o.Description) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &o.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &o.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &o.Resource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationsList. +func (o OperationsList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationsList. +func (o *OperationsList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &o.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &o.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PatchObject. +func (p PatchObject) 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 PatchObject. +func (p *PatchObject) 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 PatchProperties. +func (p PatchProperties) 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 PatchProperties. +func (p *PatchProperties) 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 PrometheusEnrichmentItem. +func (p PrometheusEnrichmentItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "datasources", p.Datasources) + populate(objectMap, "description", p.Description) + populate(objectMap, "errorMessage", p.ErrorMessage) + populate(objectMap, "grafanaExplorePath", p.GrafanaExplorePath) + populate(objectMap, "linkToApi", p.LinkToAPI) + populate(objectMap, "query", p.Query) + populate(objectMap, "status", p.Status) + populate(objectMap, "title", p.Title) + objectMap["type"] = "PrometheusEnrichmentItem" + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrometheusEnrichmentItem. +func (p *PrometheusEnrichmentItem) 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 "datasources": + err = unpopulate(val, "Datasources", &p.Datasources) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &p.Description) + delete(rawMsg, key) + case "errorMessage": + err = unpopulate(val, "ErrorMessage", &p.ErrorMessage) + delete(rawMsg, key) + case "grafanaExplorePath": + err = unpopulate(val, "GrafanaExplorePath", &p.GrafanaExplorePath) + delete(rawMsg, key) + case "linkToApi": + err = unpopulate(val, "LinkToAPI", &p.LinkToAPI) + delete(rawMsg, key) + case "query": + err = unpopulate(val, "Query", &p.Query) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &p.Status) + delete(rawMsg, key) + case "title": + err = unpopulate(val, "Title", &p.Title) + 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 PrometheusInstantQuery. +func (p PrometheusInstantQuery) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "datasources", p.Datasources) + populate(objectMap, "description", p.Description) + populate(objectMap, "errorMessage", p.ErrorMessage) + populate(objectMap, "grafanaExplorePath", p.GrafanaExplorePath) + populate(objectMap, "linkToApi", p.LinkToAPI) + populate(objectMap, "query", p.Query) + populate(objectMap, "status", p.Status) + populate(objectMap, "time", p.Time) + populate(objectMap, "title", p.Title) + objectMap["type"] = TypePrometheusInstantQuery + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrometheusInstantQuery. +func (p *PrometheusInstantQuery) 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 "datasources": + err = unpopulate(val, "Datasources", &p.Datasources) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &p.Description) + delete(rawMsg, key) + case "errorMessage": + err = unpopulate(val, "ErrorMessage", &p.ErrorMessage) + delete(rawMsg, key) + case "grafanaExplorePath": + err = unpopulate(val, "GrafanaExplorePath", &p.GrafanaExplorePath) + delete(rawMsg, key) + case "linkToApi": + err = unpopulate(val, "LinkToAPI", &p.LinkToAPI) + delete(rawMsg, key) + case "query": + err = unpopulate(val, "Query", &p.Query) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &p.Status) + delete(rawMsg, key) + case "time": + err = unpopulate(val, "Time", &p.Time) + delete(rawMsg, key) + case "title": + err = unpopulate(val, "Title", &p.Title) + 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 PrometheusRangeQuery. +func (p PrometheusRangeQuery) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "datasources", p.Datasources) + populate(objectMap, "description", p.Description) + populateDateTimeRFC3339(objectMap, "end", p.End) + populate(objectMap, "errorMessage", p.ErrorMessage) + populate(objectMap, "grafanaExplorePath", p.GrafanaExplorePath) + populate(objectMap, "linkToApi", p.LinkToAPI) + populate(objectMap, "query", p.Query) + populateDateTimeRFC3339(objectMap, "start", p.Start) + populate(objectMap, "status", p.Status) + populate(objectMap, "step", p.Step) + populate(objectMap, "title", p.Title) + objectMap["type"] = TypePrometheusRangeQuery + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrometheusRangeQuery. +func (p *PrometheusRangeQuery) 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 "datasources": + err = unpopulate(val, "Datasources", &p.Datasources) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &p.Description) + delete(rawMsg, key) + case "end": + err = unpopulateDateTimeRFC3339(val, "End", &p.End) + delete(rawMsg, key) + case "errorMessage": + err = unpopulate(val, "ErrorMessage", &p.ErrorMessage) + delete(rawMsg, key) + case "grafanaExplorePath": + err = unpopulate(val, "GrafanaExplorePath", &p.GrafanaExplorePath) + delete(rawMsg, key) + case "linkToApi": + err = unpopulate(val, "LinkToAPI", &p.LinkToAPI) + delete(rawMsg, key) + case "query": + err = unpopulate(val, "Query", &p.Query) + delete(rawMsg, key) + case "start": + err = unpopulateDateTimeRFC3339(val, "Start", &p.Start) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &p.Status) + delete(rawMsg, key) + case "step": + err = unpopulate(val, "Step", &p.Step) + delete(rawMsg, key) + case "title": + err = unpopulate(val, "Title", &p.Title) + 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 PrometheusRule. +func (p PrometheusRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actions", p.Actions) + populate(objectMap, "alert", p.Alert) + populate(objectMap, "annotations", p.Annotations) + populate(objectMap, "enabled", p.Enabled) + populate(objectMap, "expression", p.Expression) + populate(objectMap, "for", p.For) + populate(objectMap, "labels", p.Labels) + populate(objectMap, "record", p.Record) + populate(objectMap, "resolveConfiguration", p.ResolveConfiguration) + populate(objectMap, "severity", p.Severity) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type 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", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "actions": + err = unpopulate(val, "Actions", &p.Actions) + delete(rawMsg, key) + case "alert": + err = unpopulate(val, "Alert", &p.Alert) + delete(rawMsg, key) + 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", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PrometheusRuleGroupAction. +func (p PrometheusRuleGroupAction) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actionGroupId", p.ActionGroupID) + populate(objectMap, "actionProperties", p.ActionProperties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrometheusRuleGroupAction. +func (p *PrometheusRuleGroupAction) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "actionGroupId": + err = unpopulate(val, "ActionGroupID", &p.ActionGroupID) + delete(rawMsg, key) + case "actionProperties": + err = unpopulate(val, "ActionProperties", &p.ActionProperties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PrometheusRuleGroupProperties. +func (p PrometheusRuleGroupProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "clusterName", p.ClusterName) + populate(objectMap, "description", p.Description) + populate(objectMap, "enabled", p.Enabled) + populate(objectMap, "interval", p.Interval) + populate(objectMap, "rules", p.Rules) + populate(objectMap, "scopes", p.Scopes) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrometheusRuleGroupProperties. +func (p *PrometheusRuleGroupProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "clusterName": + err = unpopulate(val, "ClusterName", &p.ClusterName) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &p.Description) + delete(rawMsg, key) + case "enabled": + err = unpopulate(val, "Enabled", &p.Enabled) + delete(rawMsg, key) + case "interval": + err = unpopulate(val, "Interval", &p.Interval) + delete(rawMsg, key) + case "rules": + err = unpopulate(val, "Rules", &p.Rules) + delete(rawMsg, key) + case "scopes": + err = unpopulate(val, "Scopes", &p.Scopes) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", m, err) + return fmt.Errorf("unmarshalling type %T: %v", p, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type MonthlyRecurrence. -func (m MonthlyRecurrence) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type PrometheusRuleGroupResource. +func (p PrometheusRuleGroupResource) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "daysOfMonth", m.DaysOfMonth) - populate(objectMap, "endTime", m.EndTime) - objectMap["recurrenceType"] = RecurrenceTypeMonthly - populate(objectMap, "startTime", m.StartTime) + 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 MonthlyRecurrence. -func (m *MonthlyRecurrence) UnmarshalJSON(data []byte) error { +// 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", m, err) + return fmt.Errorf("unmarshalling type %T: %v", p, err) } for key, val := range rawMsg { var err error switch key { - case "daysOfMonth": - err = unpopulate(val, "DaysOfMonth", &m.DaysOfMonth) + case "id": + err = unpopulate(val, "ID", &p.ID) delete(rawMsg, key) - case "endTime": - err = unpopulate(val, "EndTime", &m.EndTime) + case "location": + err = unpopulate(val, "Location", &p.Location) delete(rawMsg, key) - case "recurrenceType": - err = unpopulate(val, "RecurrenceType", &m.RecurrenceType) + case "name": + err = unpopulate(val, "Name", &p.Name) delete(rawMsg, key) - case "startTime": - err = unpopulate(val, "StartTime", &m.StartTime) + 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", m, err) + return fmt.Errorf("unmarshalling type %T: %v", p, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type Operation. -func (o Operation) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type PrometheusRuleGroupResourceCollection. +func (p PrometheusRuleGroupResourceCollection) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "display", o.Display) - populate(objectMap, "name", o.Name) - populate(objectMap, "origin", o.Origin) + populate(objectMap, "value", p.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. -func (o *Operation) UnmarshalJSON(data []byte) error { +// 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", o, err) + return fmt.Errorf("unmarshalling type %T: %v", p, err) } for key, val := range rawMsg { var err error switch key { - case "display": - err = unpopulate(val, "Display", &o.Display) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &o.Name) - delete(rawMsg, key) - case "origin": - err = unpopulate(val, "Origin", &o.Origin) + case "value": + err = unpopulate(val, "Value", &p.Value) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) + return fmt.Errorf("unmarshalling type %T: %v", p, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. -func (o OperationDisplay) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type PrometheusRuleGroupResourcePatchParameters. +func (p PrometheusRuleGroupResourcePatchParameters) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "description", o.Description) - populate(objectMap, "operation", o.Operation) - populate(objectMap, "provider", o.Provider) - populate(objectMap, "resource", o.Resource) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "tags", p.Tags) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay. -func (o *OperationDisplay) UnmarshalJSON(data []byte) error { +// 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", o, err) + return fmt.Errorf("unmarshalling type %T: %v", p, err) } for key, val := range rawMsg { var err error switch key { - case "description": - err = unpopulate(val, "Description", &o.Description) - delete(rawMsg, key) - case "operation": - err = unpopulate(val, "Operation", &o.Operation) - delete(rawMsg, key) - case "provider": - err = unpopulate(val, "Provider", &o.Provider) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) delete(rawMsg, key) - case "resource": - err = unpopulate(val, "Resource", &o.Resource) + case "tags": + err = unpopulate(val, "Tags", &p.Tags) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) + return fmt.Errorf("unmarshalling type %T: %v", p, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type OperationsList. -func (o OperationsList) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type PrometheusRuleGroupResourcePatchParametersProperties. +func (p PrometheusRuleGroupResourcePatchParametersProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", o.NextLink) - populate(objectMap, "value", o.Value) + populate(objectMap, "enabled", p.Enabled) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type OperationsList. -func (o *OperationsList) UnmarshalJSON(data []byte) error { +// 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", o, err) + return fmt.Errorf("unmarshalling type %T: %v", p, err) } for key, val := range rawMsg { var err error switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &o.NextLink) - delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &o.Value) + case "enabled": + err = unpopulate(val, "Enabled", &p.Enabled) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) + return fmt.Errorf("unmarshalling type %T: %v", p, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type PatchObject. -func (p PatchObject) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type PrometheusRuleResolveConfiguration. +func (p PrometheusRuleResolveConfiguration) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "properties", p.Properties) - populate(objectMap, "tags", p.Tags) + populate(objectMap, "autoResolved", p.AutoResolved) + populate(objectMap, "timeToResolve", p.TimeToResolve) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type PatchObject. -func (p *PatchObject) UnmarshalJSON(data []byte) error { +// 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) @@ -1259,11 +2316,11 @@ func (p *PatchObject) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "properties": - err = unpopulate(val, "Properties", &p.Properties) + case "autoResolved": + err = unpopulate(val, "AutoResolved", &p.AutoResolved) delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &p.Tags) + case "timeToResolve": + err = unpopulate(val, "TimeToResolve", &p.TimeToResolve) delete(rawMsg, key) } if err != nil { @@ -1273,15 +2330,18 @@ func (p *PatchObject) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type PatchProperties. -func (p PatchProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ProxyResource. +func (p ProxyResource) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "enabled", p.Enabled) + 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 PatchProperties. -func (p *PatchProperties) UnmarshalJSON(data []byte) error { +// 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) @@ -1289,8 +2349,17 @@ func (p *PatchProperties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "enabled": - err = unpopulate(val, "Enabled", &p.Enabled) + 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 { @@ -1367,6 +2436,7 @@ 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) } @@ -1386,6 +2456,83 @@ func (r *Resource) UnmarshalJSON(data []byte) error { 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 ResourceAutoGenerated2. +func (r ResourceAutoGenerated2) 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 ResourceAutoGenerated2. +func (r *ResourceAutoGenerated2) 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) @@ -1397,6 +2544,49 @@ func (r *Resource) UnmarshalJSON(data []byte) error { 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 +} + // MarshalJSON implements the json.Marshaller interface for type Schedule. func (s Schedule) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1788,6 +2978,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.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/operations_client.go index 53d024a49a39..df00f2c3085d 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/operations_client.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/operations_client.go @@ -39,7 +39,7 @@ func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientO // NewListPager - List all operations available through Azure Alerts Management Resource Provider. // -// Generated from API version 2019-05-05-preview +// Generated from API version 2023-07-12-preview // - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ @@ -72,7 +72,7 @@ func (client *OperationsClient) listCreateRequest(ctx context.Context, options * return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2019-05-05-preview") + reqQP.Set("api-version", "2023-07-12-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil 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/options.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/options.go index 0797f819717a..96c12f4e7028 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/options.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/options.go @@ -42,10 +42,22 @@ type AlertProcessingRulesClientUpdateOptions struct { // placeholder for future optional parameters } +// 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 +} + // 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. @@ -112,6 +124,11 @@ type AlertsClientGetByIDOptions struct { // placeholder for future optional parameters } +// AlertsClientGetEnrichmentsOptions contains the optional parameters for the AlertsClient.GetEnrichments method. +type AlertsClientGetEnrichmentsOptions struct { + // placeholder for future optional parameters +} + // AlertsClientGetHistoryOptions contains the optional parameters for the AlertsClient.GetHistory method. type AlertsClientGetHistoryOptions struct { // placeholder for future optional parameters @@ -155,6 +172,11 @@ type AlertsClientGetSummaryOptions struct { TimeRange *TimeRange } +// AlertsClientListEnrichmentsOptions contains the optional parameters for the AlertsClient.NewListEnrichmentsPager method. +type AlertsClientListEnrichmentsOptions struct { + // placeholder for future optional parameters +} + // AlertsClientMetaDataOptions contains the optional parameters for the AlertsClient.MetaData method. type AlertsClientMetaDataOptions struct { // placeholder for future optional parameters @@ -165,6 +187,39 @@ type OperationsClientListOptions struct { // placeholder for future optional parameters } +// 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 +} + // SmartGroupsClientChangeStateOptions contains the optional parameters for the SmartGroupsClient.ChangeState method. type SmartGroupsClientChangeStateOptions struct { // placeholder for future optional parameters diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/polymorphic_helpers.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/polymorphic_helpers.go index 42155afb11bb..7a7e029ae9bf 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/polymorphic_helpers.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/polymorphic_helpers.go @@ -22,6 +22,8 @@ func unmarshalActionClassification(rawMsg json.RawMessage) (ActionClassification switch m["actionType"] { case string(ActionTypeAddActionGroups): b = &AddActionGroups{} + case string(ActionTypeCorrelateAlerts): + b = &CorrelateAlerts{} case string(ActionTypeRemoveAllActionGroups): b = &RemoveAllActionGroups{} default: @@ -52,6 +54,50 @@ func unmarshalActionClassificationArray(rawMsg json.RawMessage) ([]ActionClassif return fArray, nil } +func unmarshalAlertEnrichmentItemClassification(rawMsg json.RawMessage) (AlertEnrichmentItemClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]any + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b AlertEnrichmentItemClassification + switch m["type"] { + case "PrometheusEnrichmentItem": + b = &PrometheusEnrichmentItem{} + case string(TypePrometheusInstantQuery): + b = &PrometheusInstantQuery{} + case string(TypePrometheusRangeQuery): + b = &PrometheusRangeQuery{} + default: + b = &AlertEnrichmentItem{} + } + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil +} + +func unmarshalAlertEnrichmentItemClassificationArray(rawMsg json.RawMessage) ([]AlertEnrichmentItemClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages []json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fArray := make([]AlertEnrichmentItemClassification, len(rawMessages)) + for index, rawMessage := range rawMessages { + f, err := unmarshalAlertEnrichmentItemClassification(rawMessage) + if err != nil { + return nil, err + } + fArray[index] = f + } + return fArray, nil +} + func unmarshalAlertsMetaDataPropertiesClassification(rawMsg json.RawMessage) (AlertsMetaDataPropertiesClassification, error) { if rawMsg == nil { return nil, nil diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/prometheusrulegroups_client.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/prometheusrulegroups_client.go new file mode 100644 index 000000000000..88b1d9088664 --- /dev/null +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/prometheusrulegroups_client.go @@ -0,0 +1,419 @@ +//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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +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, 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) { + var err error + const operationName = "PrometheusRuleGroupsClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, ruleGroupName, parameters, options) + if err != nil { + return PrometheusRuleGroupsClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PrometheusRuleGroupsClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return PrometheusRuleGroupsClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// 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"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// 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) { + var err error + const operationName = "PrometheusRuleGroupsClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, ruleGroupName, options) + if err != nil { + return PrometheusRuleGroupsClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PrometheusRuleGroupsClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return PrometheusRuleGroupsClientDeleteResponse{}, err + } + 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) { + var err error + const operationName = "PrometheusRuleGroupsClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, ruleGroupName, options) + if err != nil { + return PrometheusRuleGroupsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PrometheusRuleGroupsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return PrometheusRuleGroupsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// 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) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PrometheusRuleGroupsClient.NewListByResourceGroupPager") + 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) + }, + Tracer: client.internal.Tracer(), + }) +} + +// 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) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PrometheusRuleGroupsClient.NewListBySubscriptionPager") + 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) + }, + Tracer: client.internal.Tracer(), + }) +} + +// 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) { + var err error + const operationName = "PrometheusRuleGroupsClient.Update" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, ruleGroupName, parameters, options) + if err != nil { + return PrometheusRuleGroupsClientUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PrometheusRuleGroupsClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return PrometheusRuleGroupsClientUpdateResponse{}, err + } + resp, err := client.updateHandleResponse(httpResp) + return resp, err +} + +// 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"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// 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 a7bb9bdff918..4a32ef17966a 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/response_types.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/response_types.go @@ -59,6 +59,18 @@ type AlertProcessingRulesClientUpdateResponse struct { XMSRequestID *string } +// AlertRuleRecommendationsClientListByResourceResponse contains the response from method AlertRuleRecommendationsClient.NewListByResourcePager. +type AlertRuleRecommendationsClientListByResourceResponse struct { + // List of alert rule recommendations. + AlertRuleRecommendationsListResponse +} + +// AlertRuleRecommendationsClientListByTargetTypeResponse contains the response from method AlertRuleRecommendationsClient.NewListByTargetTypePager. +type AlertRuleRecommendationsClientListByTargetTypeResponse struct { + // List of alert rule recommendations. + AlertRuleRecommendationsListResponse +} + // AlertsClientChangeStateResponse contains the response from method AlertsClient.ChangeState. type AlertsClientChangeStateResponse struct { // An alert created in alert management service. @@ -77,6 +89,12 @@ type AlertsClientGetByIDResponse struct { Alert } +// AlertsClientGetEnrichmentsResponse contains the response from method AlertsClient.GetEnrichments. +type AlertsClientGetEnrichmentsResponse struct { + // The alert's enrichments. + AlertEnrichmentResponse +} + // AlertsClientGetHistoryResponse contains the response from method AlertsClient.GetHistory. type AlertsClientGetHistoryResponse struct { // Alert Modification details @@ -89,6 +107,12 @@ type AlertsClientGetSummaryResponse struct { AlertsSummary } +// AlertsClientListEnrichmentsResponse contains the response from method AlertsClient.NewListEnrichmentsPager. +type AlertsClientListEnrichmentsResponse struct { + // List the alert's enrichments. + AlertEnrichmentsList +} + // AlertsClientMetaDataResponse contains the response from method AlertsClient.MetaData. type AlertsClientMetaDataResponse struct { // alert meta data information. @@ -101,6 +125,41 @@ type OperationsClientListResponse struct { OperationsList } +// PrometheusRuleGroupsClientCreateOrUpdateResponse contains the response from method PrometheusRuleGroupsClient.CreateOrUpdate. +type PrometheusRuleGroupsClientCreateOrUpdateResponse struct { + // The Prometheus rule group resource. + 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 { + // The Prometheus rule group resource. + PrometheusRuleGroupResource +} + +// PrometheusRuleGroupsClientListByResourceGroupResponse contains the response from method PrometheusRuleGroupsClient.NewListByResourceGroupPager. +type PrometheusRuleGroupsClientListByResourceGroupResponse struct { + // Represents a collection of alert rule resources. + PrometheusRuleGroupResourceCollection +} + +// PrometheusRuleGroupsClientListBySubscriptionResponse contains the response from method PrometheusRuleGroupsClient.NewListBySubscriptionPager. +type PrometheusRuleGroupsClientListBySubscriptionResponse struct { + // Represents a collection of alert rule resources. + PrometheusRuleGroupResourceCollection +} + +// PrometheusRuleGroupsClientUpdateResponse contains the response from method PrometheusRuleGroupsClient.Update. +type PrometheusRuleGroupsClientUpdateResponse struct { + // The Prometheus rule group resource. + PrometheusRuleGroupResource +} + // SmartGroupsClientChangeStateResponse contains the response from method SmartGroupsClient.ChangeState. type SmartGroupsClientChangeStateResponse struct { // Set of related alerts grouped together smartly by AMS. 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 d5ff55212622..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:09.000Z"); 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:09.000Z"); 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:01.000Z"); 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.202Z"); 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:09.000Z"); 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:09.000Z"); 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:09.000Z"); 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:09.000Z"); 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"), - // }, - // } -}