diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/CHANGELOG.md b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/CHANGELOG.md index 9b9abe1626af..20a4089e9971 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/CHANGELOG.md +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/CHANGELOG.md @@ -1,5 +1,162 @@ # Release History +## 0.11.0 (2025-05-13) +### Breaking Changes + +- Function `NewAlertsClient` parameter(s) have been changed from `(string, azcore.TokenCredential, *arm.ClientOptions)` to `(azcore.TokenCredential, *arm.ClientOptions)` +- 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)` +- Function `NewClientFactory` parameter(s) have been changed from `(string, azcore.TokenCredential, *arm.ClientOptions)` to `(string, string, azcore.TokenCredential, *arm.ClientOptions)` +- Function `*PrometheusRuleGroupsClient.Update` parameter(s) have been changed from `(context.Context, string, string, PrometheusRuleGroupResourcePatch, *PrometheusRuleGroupsClientUpdateOptions)` to `(context.Context, string, string, PrometheusRuleGroupResourcePatchParameters, *PrometheusRuleGroupsClientUpdateOptions)` +- Function `*ClientFactory.NewTenantActivityLogAlertsClient` has been removed +- Function `NewTenantActivityLogAlertsClient` has been removed +- Function `*TenantActivityLogAlertsClient.CreateOrUpdate` has been removed +- Function `*TenantActivityLogAlertsClient.Delete` has been removed +- Function `*TenantActivityLogAlertsClient.Get` has been removed +- Function `*TenantActivityLogAlertsClient.NewListByManagementGroupPager` has been removed +- Function `*TenantActivityLogAlertsClient.NewListByTenantPager` has been removed +- Function `*TenantActivityLogAlertsClient.Update` has been removed +- Struct `ActionGroup` has been removed +- Struct `ActionList` has been removed +- Struct `AlertRuleAllOfCondition` has been removed +- Struct `AlertRuleAnyOfOrLeafCondition` has been removed +- Struct `AlertRuleLeafCondition` has been removed +- Struct `AlertRuleProperties` has been removed +- Struct `PrometheusRuleGroupResourcePatch` has been removed +- Struct `PrometheusRuleGroupResourcePatchProperties` has been removed +- Struct `TenantActivityLogAlertResource` has been removed +- Struct `TenantAlertRuleList` has been removed +- Struct `TenantAlertRulePatchObject` has been removed +- Struct `TenantAlertRulePatchProperties` has been removed + +### Features Added + +- New value `AlertStateFired`, `AlertStateFiring`, `AlertStateNoAlert`, `AlertStateResolved`, `AlertStateResolving` added to enum type `AlertState` +- New value `MonitorServiceResourceHealth` added to enum type `MonitorService` +- New enum type `AbnormalEventType` with values `AbnormalEventTypeDependency`, `AbnormalEventTypeException`, `AbnormalEventTypeRequest` +- New enum type `AddedByType` with values `AddedByTypeAutomatic`, `AddedByTypeManual` +- New enum type `AggregationType` with values `AggregationTypeAverage`, `AggregationTypeCount`, `AggregationTypeMaximum`, `AggregationTypeMinimum`, `AggregationTypeNone`, `AggregationTypeTotal`, `AggregationTypeUnique` +- New enum type `AlertSeverity` with values `AlertSeverityFour`, `AlertSeverityOne`, `AlertSeverityThree`, `AlertSeverityTwo`, `AlertSeverityZero` +- New enum type `AnomalyDirection` with values `AnomalyDirectionDecrease`, `AnomalyDirectionIncrease`, `AnomalyDirectionIncreaseAndDecrease` +- New enum type `AvailabilityState` with values `AvailabilityStateAvailable`, `AvailabilityStateDegraded`, `AvailabilityStateUnavailable`, `AvailabilityStateUnknown`, `AvailabilityStateUserInitiated` +- New enum type `CategoryType` with values `CategoryTypeAlert`, `CategoryTypeDiagnostics`, `CategoryTypeInvestigation`, `CategoryTypeLog`, `CategoryTypeMetric`, `CategoryTypeResourceHealth` +- New enum type `ConditionOperator` with values `ConditionOperatorEquals`, `ConditionOperatorGreaterOrLessThan`, `ConditionOperatorGreaterThan`, `ConditionOperatorGreaterThanOrEqual`, `ConditionOperatorLessThan`, `ConditionOperatorLessThanOrEqual` +- New enum type `CriterionType` with values `CriterionTypeDynamicThresholdCriterion`, `CriterionTypeStaticThresholdCriterion` +- New enum type `DetailsType` with values `DetailsTypeAbnormalEvent`, `DetailsTypeAzureMetric`, `DetailsTypeDiagnostics`, `DetailsTypeFinding`, `DetailsTypeInvestigation`, `DetailsTypeRelatedAlert`, `DetailsTypeResourceHealth` +- New enum type `DimensionOperator` with values `DimensionOperatorExclude`, `DimensionOperatorInclude` +- New enum type `HealthState` with values `HealthStateHealthy`, `HealthStateUnhealthy`, `HealthStateUnknown` +- New enum type `InvestigationEntityType` with values `InvestigationEntityTypeEvidence`, `InvestigationEntityTypeFinding`, `InvestigationEntityTypeInvestigation` +- New enum type `InvestigationExecutionRunState` with values `InvestigationExecutionRunStateCanceled`, `InvestigationExecutionRunStateFailed`, `InvestigationExecutionRunStateInProgress`, `InvestigationExecutionRunStateNone`, `InvestigationExecutionRunStateSucceeded` +- New enum type `Kind` with values `KindEventLogAlert`, `KindLogAlert`, `KindLogToMetric` +- New enum type `Relevance` with values `RelevanceIrrelevant`, `RelevanceNone`, `RelevanceRelevant` +- New enum type `ResourceProvisioningState` with values `ResourceProvisioningStateCanceled`, `ResourceProvisioningStateFailed`, `ResourceProvisioningStateSucceeded` +- New enum type `Status` with values `StatusCanceled`, `StatusClosed`, `StatusFailed`, `StatusInProgress`, `StatusMitigated`, `StatusNew`, `StatusSucceeded` +- New enum type `TimeAggregation` with values `TimeAggregationAverage`, `TimeAggregationCount`, `TimeAggregationMaximum`, `TimeAggregationMinimum`, `TimeAggregationTotal` +- New enum type `Type` with values `TypePrometheusInstantQuery`, `TypePrometheusRangeQuery` +- New function `*AbnormalEventDetails.GetDetailsBase() *DetailsBase` +- New function `*AlertEnrichmentItem.GetAlertEnrichmentItem() *AlertEnrichmentItem` +- New function `*AlertsClient.GetEnrichments(context.Context, string, string, *AlertsClientGetEnrichmentsOptions) (AlertsClientGetEnrichmentsResponse, error)` +- New function `*AlertsClient.NewListEnrichmentsPager(string, string, *AlertsClientListEnrichmentsOptions) *runtime.Pager[AlertsClientListEnrichmentsResponse]` +- New function `*AzureMetricDetails.GetDetailsBase() *DetailsBase` +- New function `NewClient(string, azcore.TokenCredential, *arm.ClientOptions) (*Client, error)` +- New function `*Client.PreviewAlertRule(context.Context, PreviewAlertRuleRequest, *ClientPreviewAlertRuleOptions) (ClientPreviewAlertRuleResponse, error)` +- New function `*ClientFactory.NewClient() *Client` +- New function `*ClientFactory.NewIssueClient() *IssueClient` +- New function `*DetailsBase.GetDetailsBase() *DetailsBase` +- New function `*DiagnosticsSolutionDetails.GetDetailsBase() *DetailsBase` +- New function `*InvestigationDetails.GetDetailsBase() *DetailsBase` +- New function `NewIssueClient(string, azcore.TokenCredential, *arm.ClientOptions) (*IssueClient, error)` +- New function `*IssueClient.AddOrUpdateAlerts(context.Context, string, RelatedAlerts, *IssueClientAddOrUpdateAlertsOptions) (IssueClientAddOrUpdateAlertsResponse, error)` +- New function `*IssueClient.AddOrUpdateResources(context.Context, string, RelatedResources, *IssueClientAddOrUpdateResourcesOptions) (IssueClientAddOrUpdateResourcesResponse, error)` +- New function `*IssueClient.Create(context.Context, string, IssueResource, *IssueClientCreateOptions) (IssueClientCreateResponse, error)` +- New function `*IssueClient.Delete(context.Context, string, *IssueClientDeleteOptions) (IssueClientDeleteResponse, error)` +- New function `*IssueClient.FetchInvestigationResult(context.Context, string, FetchInvestigationResultParameters, *IssueClientFetchInvestigationResultOptions) (IssueClientFetchInvestigationResultResponse, error)` +- New function `*IssueClient.Get(context.Context, string, *IssueClientGetOptions) (IssueClientGetResponse, error)` +- New function `*IssueClient.NewListAlertsPager(string, ListParameter, *IssueClientListAlertsOptions) *runtime.Pager[IssueClientListAlertsResponse]` +- New function `*IssueClient.NewListPager(string, *IssueClientListOptions) *runtime.Pager[IssueClientListResponse]` +- New function `*IssueClient.NewListResourcesPager(string, ListParameter, *IssueClientListResourcesOptions) *runtime.Pager[IssueClientListResourcesResponse]` +- New function `*IssueClient.StartInvestigation(context.Context, string, StartInvestigationParameters, *IssueClientStartInvestigationOptions) (IssueClientStartInvestigationResponse, error)` +- New function `*IssueClient.Update(context.Context, string, IssueResourceUpdate, *IssueClientUpdateOptions) (IssueClientUpdateResponse, error)` +- 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 `*RelatedAlertDetails.GetDetailsBase() *DetailsBase` +- New function `*ResourceHealthDetails.GetDetailsBase() *DetailsBase` +- New struct `AbnormalEventAnomalyInsight` +- New struct `AbnormalEventData` +- New struct `AbnormalEventDetails` +- New struct `AlertEnrichmentProperties` +- New struct `AlertEnrichmentResponse` +- New struct `AlertEnrichmentsList` +- New struct `AnomalyRange` +- New struct `AzureMetricAnomalyInsight` +- New struct `AzureMetricData` +- New struct `AzureMetricDetails` +- New struct `BaselineRange` +- New struct `CorrelationDetails` +- New struct `DiagnosticsInsight` +- New struct `DiagnosticsSolutionDetails` +- New struct `DimensionNameAndValue` +- New struct `EvaluatedPeriod` +- New struct `Evaluation` +- New struct `ExceptionPatternAnomaly` +- New struct `FetchInvestigationResultParameters` +- New struct `InvestigationDetails` +- New struct `InvestigationEntity` +- New struct `InvestigationExecution` +- New struct `InvestigationMetadata` +- New struct `InvestigationResult` +- New struct `InvestigationScope` +- New struct `IssueProperties` +- New struct `IssuePropertiesUpdate` +- New struct `IssueResource` +- New struct `IssueResourceListResult` +- New struct `IssueResourceUpdate` +- New struct `ListParameter` +- New struct `LogAlertRuleCondition` +- New struct `LogAlertRuleConditionFailingPeriods` +- New struct `LogAlertRuleCriteria` +- New struct `LogAlertRuleDimension` +- New struct `LogAlertRuleProperties` +- New struct `LogAlertRuleResolveConfiguration` +- New struct `LogAlertRuleResource` +- New struct `Origin` +- New struct `PagedRelatedAlert` +- New struct `PagedRelatedResource` +- New struct `PreviewAlertRuleRequest` +- New struct `PreviewAlertRuleRequestProperties` +- New struct `PreviewAlertRuleResponse` +- New struct `PrometheusInstantQuery` +- New struct `PrometheusRangeQuery` +- New struct `PrometheusRuleGroupResourcePatchParameters` +- New struct `PrometheusRuleGroupResourcePatchParametersProperties` +- New struct `RelatedAlert` +- New struct `RelatedAlertAnomalyInsight` +- New struct `RelatedAlertData` +- New struct `RelatedAlertDetails` +- New struct `RelatedAlerts` +- New struct `RelatedResource` +- New struct `RelatedResources` +- New struct `ResourceHealthDetails` +- New struct `ResourceHealthInsight` +- New struct `RulePreviewResult` +- New struct `RunParameters` +- New struct `StartInvestigationParameters` +- New struct `Summary` +- New struct `TracePatternAnomaly` +- New struct `TransactionEdge` +- New struct `TransactionNode` +- New struct `TransactionPatternAnomaly` +- New field `Category` in struct `AlertRuleRecommendationProperties` +- New field `CorrelationDetails`, `HasEnrichments`, `IsStatefulAlert` in struct `Essentials` + + ## 0.10.0 (2024-03-01) ### Breaking Changes diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/README.md b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/README.md index aef7195dc193..c66633b2c950 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/README.md +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/README.md @@ -36,7 +36,7 @@ For more information on authentication, please see the documentation for `aziden Azure Alerts Management module consists of one or more clients. We provide a client factory which could be used to create any client in this module. ```go -clientFactory, err := armalertsmanagement.NewClientFactory(, cred, nil) +clientFactory, err := armalertsmanagement.NewClientFactory(, , cred, nil) ``` You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). @@ -47,7 +47,7 @@ options := arm.ClientOptions { Cloud: cloud.AzureChina, }, } -clientFactory, err := armalertsmanagement.NewClientFactory(, cred, &options) +clientFactory, err := armalertsmanagement.NewClientFactory(, , cred, &options) ``` ## Clients diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alertprocessingrules_client.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alertprocessingrules_client.go index e61ee2fa2ff7..f13c631a594e 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alertprocessingrules_client.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alertprocessingrules_client.go @@ -1,6 +1,3 @@ -//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. @@ -46,7 +43,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 2021-08-08-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. @@ -75,7 +72,7 @@ func (client *AlertProcessingRulesClient) CreateOrUpdate(ctx context.Context, re } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *AlertProcessingRulesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, alertProcessingRuleName string, alertProcessingRule AlertProcessingRule, options *AlertProcessingRulesClientCreateOrUpdateOptions) (*policy.Request, error) { +func (client *AlertProcessingRulesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, alertProcessingRuleName string, alertProcessingRule AlertProcessingRule, _ *AlertProcessingRulesClientCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules/{alertProcessingRuleName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -94,7 +91,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", "2021-08-08-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, alertProcessingRule); err != nil { @@ -118,7 +115,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 2021-08-08-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 @@ -146,7 +143,7 @@ func (client *AlertProcessingRulesClient) Delete(ctx context.Context, resourceGr } // deleteCreateRequest creates the Delete request. -func (client *AlertProcessingRulesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, alertProcessingRuleName string, options *AlertProcessingRulesClientDeleteOptions) (*policy.Request, error) { +func (client *AlertProcessingRulesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, alertProcessingRuleName string, _ *AlertProcessingRulesClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules/{alertProcessingRuleName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -165,7 +162,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", "2021-08-08-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -183,7 +180,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 2021-08-08-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 @@ -211,7 +208,7 @@ func (client *AlertProcessingRulesClient) GetByName(ctx context.Context, resourc } // getByNameCreateRequest creates the GetByName request. -func (client *AlertProcessingRulesClient) getByNameCreateRequest(ctx context.Context, resourceGroupName string, alertProcessingRuleName string, options *AlertProcessingRulesClientGetByNameOptions) (*policy.Request, error) { +func (client *AlertProcessingRulesClient) getByNameCreateRequest(ctx context.Context, resourceGroupName string, alertProcessingRuleName string, _ *AlertProcessingRulesClientGetByNameOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules/{alertProcessingRuleName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -230,7 +227,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", "2021-08-08-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -250,7 +247,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 2021-08-08-preview // - resourceGroupName - Resource group name where the resource is created. // - options - AlertProcessingRulesClientListByResourceGroupOptions contains the optional parameters for the AlertProcessingRulesClient.NewListByResourceGroupPager // method. @@ -278,7 +275,7 @@ func (client *AlertProcessingRulesClient) NewListByResourceGroupPager(resourceGr } // listByResourceGroupCreateRequest creates the ListByResourceGroup request. -func (client *AlertProcessingRulesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *AlertProcessingRulesClientListByResourceGroupOptions) (*policy.Request, error) { +func (client *AlertProcessingRulesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, _ *AlertProcessingRulesClientListByResourceGroupOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -293,7 +290,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", "2021-08-08-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -313,7 +310,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 2021-08-08-preview // - options - AlertProcessingRulesClientListBySubscriptionOptions contains the optional parameters for the AlertProcessingRulesClient.NewListBySubscriptionPager // method. func (client *AlertProcessingRulesClient) NewListBySubscriptionPager(options *AlertProcessingRulesClientListBySubscriptionOptions) *runtime.Pager[AlertProcessingRulesClientListBySubscriptionResponse] { @@ -340,7 +337,7 @@ func (client *AlertProcessingRulesClient) NewListBySubscriptionPager(options *Al } // listBySubscriptionCreateRequest creates the ListBySubscription request. -func (client *AlertProcessingRulesClient) listBySubscriptionCreateRequest(ctx context.Context, options *AlertProcessingRulesClientListBySubscriptionOptions) (*policy.Request, error) { +func (client *AlertProcessingRulesClient) listBySubscriptionCreateRequest(ctx context.Context, _ *AlertProcessingRulesClientListBySubscriptionOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/actionRules" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -351,7 +348,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", "2021-08-08-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -372,7 +369,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 2021-08-08-preview // - resourceGroupName - Resource group name where the resource is created. // - alertProcessingRuleName - The name that needs to be updated. // - alertProcessingRulePatch - Parameters supplied to the operation. @@ -401,7 +398,7 @@ func (client *AlertProcessingRulesClient) Update(ctx context.Context, resourceGr } // updateCreateRequest creates the Update request. -func (client *AlertProcessingRulesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, alertProcessingRuleName string, alertProcessingRulePatch PatchObject, options *AlertProcessingRulesClientUpdateOptions) (*policy.Request, error) { +func (client *AlertProcessingRulesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, alertProcessingRuleName string, alertProcessingRulePatch PatchObject, _ *AlertProcessingRulesClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules/{alertProcessingRuleName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -420,7 +417,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", "2021-08-08-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 0ce3a001d462..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/6d2438481021a94793b07b226df06d5f3c61d51d/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/6d2438481021a94793b07b226df06d5f3c61d51d/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/6d2438481021a94793b07b226df06d5f3c61d51d/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/6d2438481021a94793b07b226df06d5f3c61d51d/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/6d2438481021a94793b07b226df06d5f3c61d51d/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/6d2438481021a94793b07b226df06d5f3c61d51d/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/6d2438481021a94793b07b226df06d5f3c61d51d/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/6d2438481021a94793b07b226df06d5f3c61d51d/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/6d2438481021a94793b07b226df06d5f3c61d51d/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/6d2438481021a94793b07b226df06d5f3c61d51d/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/6d2438481021a94793b07b226df06d5f3c61d51d/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 index f8c3a576cc91..fe7705911712 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alertrulerecommendations_client.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alertrulerecommendations_client.go @@ -1,6 +1,3 @@ -//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. @@ -45,7 +42,7 @@ func NewAlertRuleRecommendationsClient(subscriptionID string, credential azcore. // NewListByResourcePager - Retrieve alert rule recommendations for a resource. // -// Generated from API version 2023-01-01-preview +// 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. @@ -73,7 +70,7 @@ func (client *AlertRuleRecommendationsClient) NewListByResourcePager(resourceURI } // listByResourceCreateRequest creates the ListByResource request. -func (client *AlertRuleRecommendationsClient) listByResourceCreateRequest(ctx context.Context, resourceURI string, options *AlertRuleRecommendationsClientListByResourceOptions) (*policy.Request, error) { +func (client *AlertRuleRecommendationsClient) listByResourceCreateRequest(ctx context.Context, resourceURI string, _ *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)) @@ -81,7 +78,7 @@ func (client *AlertRuleRecommendationsClient) listByResourceCreateRequest(ctx co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-01-01-preview") + reqQP.Set("api-version", "2023-08-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -98,7 +95,7 @@ func (client *AlertRuleRecommendationsClient) listByResourceHandleResponse(resp // NewListByTargetTypePager - Retrieve alert rule recommendations for a target type. // -// Generated from API version 2023-01-01-preview +// Generated from API version 2023-08-01-preview // - targetType - The recommendations target type. // - options - AlertRuleRecommendationsClientListByTargetTypeOptions contains the optional parameters for the AlertRuleRecommendationsClient.NewListByTargetTypePager // method. @@ -126,7 +123,7 @@ func (client *AlertRuleRecommendationsClient) NewListByTargetTypePager(targetTyp } // listByTargetTypeCreateRequest creates the ListByTargetType request. -func (client *AlertRuleRecommendationsClient) listByTargetTypeCreateRequest(ctx context.Context, targetType string, options *AlertRuleRecommendationsClientListByTargetTypeOptions) (*policy.Request, error) { +func (client *AlertRuleRecommendationsClient) listByTargetTypeCreateRequest(ctx context.Context, targetType string, _ *AlertRuleRecommendationsClientListByTargetTypeOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/alertRuleRecommendations" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -137,7 +134,7 @@ func (client *AlertRuleRecommendationsClient) listByTargetTypeCreateRequest(ctx return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-01-01-preview") + 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"} diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alertrulerecommendations_client_example_test.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alertrulerecommendations_client_example_test.go deleted file mode 100644 index 6ea78d57300c..000000000000 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alertrulerecommendations_client_example_test.go +++ /dev/null @@ -1,1123 +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/6d2438481021a94793b07b226df06d5f3c61d51d/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-01-01-preview/examples/AlertRuleRecommendations_GetByResource_MAC.json -func ExampleAlertRuleRecommendationsClient_NewListByResourcePager_listAlertRuleRecommendationsForMonitoringAccountsAtResourceLevel() { - 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.NewAlertRuleRecommendationsClient().NewListByResourcePager("subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourceGroups/GenevaAlertRP-RunnerResources-eastus/providers/microsoft.monitor/accounts/alertsrp-eastus-pgms", 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.AlertRuleRecommendationsListResponse = armalertsmanagement.AlertRuleRecommendationsListResponse{ - // Value: []*armalertsmanagement.AlertRuleRecommendationResource{ - // { - // Name: to.Ptr("NodeRecordingRulesRuleGroup"), - // Type: to.Ptr("Microsoft.AlertsManagement/alertRuleRecommendations"), - // ID: to.Ptr("/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourceGroups/GenevaAlertRP-RunnerResources-eastus/providers/microsoft.monitor/accounts/alertsrp-eastus-pgms/providers/Microsoft.AlertsManagement/alertRuleRecommendations/NodeRecordingRulesRuleGroup"), - // Properties: &armalertsmanagement.AlertRuleRecommendationProperties{ - // AlertRuleType: to.Ptr("Microsoft.AlertsManagement/prometheusRuleGroups"), - // DisplayInformation: map[string]*string{ - // "ruleInfo": to.Ptr("Rule Information for first recording rule."), - // }, - // RuleArmTemplate: &armalertsmanagement.RuleArmTemplate{ - // Schema: to.Ptr("https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#"), - // ContentVersion: to.Ptr("1.0.0.0"), - // Parameters: map[string]any{ - // "actionGroupIds":map[string]any{ - // "type": "array", - // "defaultValue":[]any{ - // }, - // "metadata":map[string]any{ - // "description": "Insert Action groups ids to attach them to the below alert rules.", - // }, - // }, - // "alertName":map[string]any{ - // "type": "string", - // "defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('clusterNameForPrometheus'))]", - // "metadata":map[string]any{ - // "description": "Name of the alert rule", - // }, - // "minLength": float64(1), - // }, - // "alertNamePrefix":map[string]any{ - // "type": "string", - // "defaultValue": "NodeRecordingRulesRuleGroup", - // "metadata":map[string]any{ - // "description": "prefix of the alert rule name", - // }, - // "minLength": float64(1), - // }, - // "clusterNameForPrometheus":map[string]any{ - // "type": "string", - // }, - // "location":map[string]any{ - // "type": "string", - // "defaultValue": "eastus", - // }, - // "targetResourceId":map[string]any{ - // "type": "string", - // "defaultValue": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourceGroups/GenevaAlertRP-RunnerResources-eastus/providers/microsoft.monitor/accounts/alertsrp-eastus-pgms", - // }, - // "targetResourceName":map[string]any{ - // "type": "string", - // "defaultValue": "alertsrp-eastus-pgms", - // }, - // }, - // Resources: []any{ - // map[string]any{ - // "name": "[parameters('alertName')]", - // "type": "Microsoft.AlertsManagement/prometheusRuleGroups", - // "apiVersion": "2021-07-22-preview", - // "location": "[parameters('location')]", - // "properties":map[string]any{ - // "description": "Node Recording Rules RuleGroup", - // "clusterName": "[parameters('clusterNameForPrometheus')]", - // "interval": "PT1M", - // "rules":[]any{ - // map[string]any{ - // "expression": "count without (cpu, mode) ( node_cpu_seconds_total{job=\"node\",mode=\"idle\"})", - // "record": "instance:node_num_cpu:sum", - // }, - // }, - // "scopes": "[variables('scopes')]", - // }, - // }}, - // Variables: map[string]any{ - // "copy":[]any{ - // map[string]any{ - // "name": "actionsForPrometheusRuleGroups", - // "count": "[length(parameters('actionGroupIds'))]", - // "input":map[string]any{ - // "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForPrometheusRuleGroups')]]", - // }, - // }, - // }, - // "scopes": "[array(parameters('targetResourceId'))]", - // }, - // }, - // }, - // }, - // { - // Name: to.Ptr("KubernetesReccordingRulesRuleGroup"), - // Type: to.Ptr("Microsoft.AlertsManagement/alertRuleRecommendations"), - // ID: to.Ptr("/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourceGroups/GenevaAlertRP-RunnerResources-eastus/providers/microsoft.monitor/accounts/alertsrp-eastus-pgms/providers/Microsoft.AlertsManagement/alertRuleRecommendations/KubernetesReccordingRulesRuleGroup"), - // Properties: &armalertsmanagement.AlertRuleRecommendationProperties{ - // AlertRuleType: to.Ptr("Microsoft.AlertsManagement/prometheusRuleGroups"), - // DisplayInformation: map[string]*string{ - // "ruleInfo": to.Ptr("Rule Information for second recording rule."), - // }, - // RuleArmTemplate: &armalertsmanagement.RuleArmTemplate{ - // Schema: to.Ptr("https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#"), - // ContentVersion: to.Ptr("1.0.0.0"), - // Parameters: map[string]any{ - // "actionGroupIds":map[string]any{ - // "type": "array", - // "defaultValue":[]any{ - // }, - // "metadata":map[string]any{ - // "description": "Insert Action groups ids to attach them to the below alert rules.", - // }, - // }, - // "alertName":map[string]any{ - // "type": "string", - // "defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('clusterNameForPrometheus'))]", - // "metadata":map[string]any{ - // "description": "Name of the alert rule", - // }, - // "minLength": float64(1), - // }, - // "alertNamePrefix":map[string]any{ - // "type": "string", - // "defaultValue": "KubernetesReccordingRulesRuleGroup", - // "metadata":map[string]any{ - // "description": "prefix of the alert rule name", - // }, - // "minLength": float64(1), - // }, - // "clusterNameForPrometheus":map[string]any{ - // "type": "string", - // }, - // "location":map[string]any{ - // "type": "string", - // "defaultValue": "eastus", - // }, - // "targetResourceId":map[string]any{ - // "type": "string", - // "defaultValue": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourceGroups/GenevaAlertRP-RunnerResources-eastus/providers/microsoft.monitor/accounts/alertsrp-eastus-pgms", - // }, - // "targetResourceName":map[string]any{ - // "type": "string", - // "defaultValue": "alertsrp-eastus-pgms", - // }, - // }, - // Resources: []any{ - // map[string]any{ - // "name": "[parameters('alertName')]", - // "type": "Microsoft.AlertsManagement/prometheusRuleGroups", - // "apiVersion": "2021-07-22-preview", - // "location": "[parameters('location')]", - // "properties":map[string]any{ - // "description": "Kubernetes Recording Rules RuleGroup", - // "clusterName": "[parameters('clusterNameForPrometheus')]", - // "interval": "PT1M", - // "rules":[]any{ - // map[string]any{ - // "expression": "sum by (cluster, namespace, pod, container) ( irate(container_cpu_usage_seconds_total{job=\"cadvisor\", image!=\"\"}[5m])) * on (cluster, namespace, pod) group_left(node) topk by (cluster, namespace, pod) ( 1, max by(cluster, namespace, pod, node) (kube_pod_info{node!=\"\"}))", - // "record": "node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate", - // }, - // }, - // "scopes": "[variables('scopes')]", - // }, - // }}, - // Variables: map[string]any{ - // "copy":[]any{ - // map[string]any{ - // "name": "actionsForPrometheusRuleGroups", - // "count": "[length(parameters('actionGroupIds'))]", - // "input":map[string]any{ - // "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForPrometheusRuleGroups')]]", - // }, - // }, - // }, - // "scopes": "[array(parameters('targetResourceId'))]", - // }, - // }, - // }, - // }, - // { - // Name: to.Ptr("KubernetesAlert-DefaultAlert"), - // Type: to.Ptr("Microsoft.AlertsManagement/alertRuleRecommendations"), - // ID: to.Ptr("/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourceGroups/GenevaAlertRP-RunnerResources-eastus/providers/microsoft.monitor/accounts/alertsrp-eastus-pgms/providers/Microsoft.AlertsManagement/alertRuleRecommendations/KubernetesAlert-DefaultAlert"), - // Properties: &armalertsmanagement.AlertRuleRecommendationProperties{ - // AlertRuleType: to.Ptr("Microsoft.AlertsManagement/prometheusRuleGroups"), - // DisplayInformation: map[string]*string{ - // "ruleInfo": to.Ptr("Rule Information for alerting rule."), - // }, - // RuleArmTemplate: &armalertsmanagement.RuleArmTemplate{ - // Schema: to.Ptr("https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#"), - // ContentVersion: to.Ptr("1.0.0.0"), - // Parameters: map[string]any{ - // "actionGroupIds":map[string]any{ - // "type": "array", - // "defaultValue":[]any{ - // }, - // "metadata":map[string]any{ - // "description": "Insert Action groups ids to attach them to the below alert rules.", - // }, - // }, - // "alertName":map[string]any{ - // "type": "string", - // "defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('clusterNameForPrometheus'))]", - // "metadata":map[string]any{ - // "description": "Name of the alert rule", - // }, - // "minLength": float64(1), - // }, - // "alertNamePrefix":map[string]any{ - // "type": "string", - // "defaultValue": "KubernetesAlert-DefaultAlerts", - // "metadata":map[string]any{ - // "description": "prefix of the alert rule name", - // }, - // "minLength": float64(1), - // }, - // "clusterNameForPrometheus":map[string]any{ - // "type": "string", - // }, - // "location":map[string]any{ - // "type": "string", - // "defaultValue": "eastus", - // }, - // "targetResourceId":map[string]any{ - // "type": "string", - // "defaultValue": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourceGroups/GenevaAlertRP-RunnerResources-eastus/providers/microsoft.monitor/accounts/alertsrp-eastus-pgms", - // }, - // "targetResourceName":map[string]any{ - // "type": "string", - // "defaultValue": "alertsrp-eastus-pgms", - // }, - // }, - // Resources: []any{ - // map[string]any{ - // "name": "[parameters('alertName')]", - // "type": "Microsoft.AlertsManagement/prometheusRuleGroups", - // "apiVersion": "2021-07-22-preview", - // "location": "[parameters('location')]", - // "properties":map[string]any{ - // "description": "Kubernetes Alert RuleGroup-DefaultAlerts", - // "clusterName": "[parameters('clusterNameForPrometheus')]", - // "interval": "PT1M", - // "rules":[]any{ - // map[string]any{ - // "Severity": float64(3), - // "actions": "[variables('actionsForPrometheusRuleGroups')]", - // "alert": "KubePodCrashLooping", - // "expression": "max_over_time(kube_pod_container_status_waiting_reason{reason=\"CrashLoopBackOff\", job=\"kube-state-metrics\"}[5m]) >= 1", - // "for": "PT15M", - // "labels":map[string]any{ - // "severity": "warning", - // }, - // }, - // map[string]any{ - // "Severity": float64(3), - // "actions": "[variables('actionsForPrometheusRuleGroups')]", - // "alert": "KubePodNotReady", - // "expression": "sum by (namespace, pod, cluster) ( max by(namespace, pod, cluster) ( kube_pod_status_phase{job=\"kube-state-metrics\", phase=~\"Pending|Unknown\"} ) * on(namespace, pod, cluster) group_left(owner_kind) topk by(namespace, pod, cluster) ( 1, max by(namespace, pod, owner_kind, cluster) (kube_pod_owner{owner_kind!=\"Job\"}) )) > 0", - // "for": "PT15M", - // "labels":map[string]any{ - // "severity": "warning", - // }, - // }, - // }, - // "scopes": "[variables('scopes')]", - // }, - // }}, - // Variables: map[string]any{ - // "copy":[]any{ - // map[string]any{ - // "name": "actionsForPrometheusRuleGroups", - // "count": "[length(parameters('actionGroupIds'))]", - // "input":map[string]any{ - // "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForPrometheusRuleGroups')]]", - // }, - // }, - // }, - // "scopes": "[array(parameters('targetResourceId'))]", - // }, - // }, - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/6d2438481021a94793b07b226df06d5f3c61d51d/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-01-01-preview/examples/AlertRuleRecommendations_GetByResource_VM.json -func ExampleAlertRuleRecommendationsClient_NewListByResourcePager_listAlertRuleRecommendationsForVirtualMachinesAtResourceLevel() { - 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.NewAlertRuleRecommendationsClient().NewListByResourcePager("subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourcegroups/test/providers/Microsoft.Compute/virtualMachines/testMachineCanBeSafelyDeleted", 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.AlertRuleRecommendationsListResponse = armalertsmanagement.AlertRuleRecommendationsListResponse{ - // Value: []*armalertsmanagement.AlertRuleRecommendationResource{ - // { - // Name: to.Ptr("Percentage CPU"), - // Type: to.Ptr("Microsoft.AlertsManagement/alertRuleRecommendations"), - // ID: to.Ptr("/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourcegroups/test/providers/Microsoft.Compute/virtualMachines/testMachineCanBeSafelyDeleted/providers/Microsoft.AlertsManagement/alertRuleRecommendations/Percentage CPU"), - // Properties: &armalertsmanagement.AlertRuleRecommendationProperties{ - // AlertRuleType: to.Ptr("Microsoft.Insights/metricAlerts"), - // DisplayInformation: map[string]*string{ - // "displayUnits": to.Ptr("Percentage"), - // "infoBallonLink": to.Ptr("Rule1 InfoBalloon Link"), - // "infoBallonMessage": to.Ptr("Rule1 InfoBalloon Message"), - // "metricDisplayName": to.Ptr("Percentage CPU"), - // }, - // RuleArmTemplate: &armalertsmanagement.RuleArmTemplate{ - // Schema: to.Ptr("https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#"), - // ContentVersion: to.Ptr("1.0.0.0"), - // Parameters: map[string]any{ - // "actionGroupIds":map[string]any{ - // "type": "array", - // "defaultValue":[]any{ - // }, - // "metadata":map[string]any{ - // "description": "Insert Action groups ids to attach them to the below alert rules.", - // }, - // }, - // "alertName":map[string]any{ - // "type": "string", - // "defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('targetResourceName'))]", - // "metadata":map[string]any{ - // "description": "Name of the alert rule", - // }, - // "minLength": float64(1), - // }, - // "alertNamePrefix":map[string]any{ - // "type": "string", - // "defaultValue": "Percentage CPU", - // "metadata":map[string]any{ - // "description": "prefix of the alert rule name", - // }, - // "minLength": float64(1), - // }, - // "alertSeverity":map[string]any{ - // "type": "int", - // "allowedValues":[]any{ - // float64(0), - // float64(1), - // float64(2), - // float64(3), - // float64(4), - // }, - // "defaultValue": float64(3), - // "metadata":map[string]any{ - // "description": "Severity of alert {0,1,2,3,4}", - // }, - // }, - // "targetResourceId":map[string]any{ - // "type": "string", - // "defaultValue": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourcegroups/test/providers/Microsoft.Compute/virtualMachines/testMachineCanBeSafelyDeleted", - // }, - // "targetResourceName":map[string]any{ - // "type": "string", - // "defaultValue": "testmachinecanbesafelydeleted", - // }, - // "threshold":map[string]any{ - // "type": "int", - // "defaultValue": float64(80), - // "metadata":map[string]any{ - // "description": "The threshold value at which the alert is activated.", - // }, - // }, - // }, - // Resources: []any{ - // map[string]any{ - // "name": "[parameters('alertName')]", - // "type": "Microsoft.Insights/metricAlerts", - // "apiVersion": "2018-03-01", - // "location": "global", - // "properties":map[string]any{ - // "description": "Percentage CPU is greater than 80 %", - // "actions": "[variables('actionsForMetricAlerts')]", - // "criteria":map[string]any{ - // "allOf":[]any{ - // map[string]any{ - // "name": "Metric1", - // "metricName": "Percentage CPU", - // "operator": "GreaterThan", - // "threshold": "[parameters('threshold')]", - // "timeAggregation": "Average", - // }, - // }, - // "odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", - // }, - // "enabled": true, - // "evaluationFrequency": "PT5M", - // "scopes": "[variables('scopes')]", - // "severity": "[parameters('alertSeverity')]", - // "windowSize": "PT5M", - // }, - // }}, - // Variables: map[string]any{ - // "copy":[]any{ - // map[string]any{ - // "name": "actionsForMetricAlerts", - // "count": "[length(parameters('actionGroupIds'))]", - // "input":map[string]any{ - // "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForMetricAlerts')]]", - // }, - // }, - // }, - // "scopes": "[array(parameters('targetResourceId'))]", - // }, - // }, - // }, - // }, - // { - // Name: to.Ptr("Available Memory Bytes"), - // Type: to.Ptr("Microsoft.AlertsManagement/alertRuleRecommendations"), - // ID: to.Ptr("/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourcegroups/test/providers/Microsoft.Compute/virtualMachines/testMachineCanBeSafelyDeleted/providers/Microsoft.AlertsManagement/alertRuleRecommendations/Available Memory Bytes"), - // Properties: &armalertsmanagement.AlertRuleRecommendationProperties{ - // AlertRuleType: to.Ptr("Microsoft.Insights/metricAlerts"), - // DisplayInformation: map[string]*string{ - // "displayUnits": to.Ptr("Gigabytes"), - // "infoBallonLink": to.Ptr("Rule2 InfoBalloon Link"), - // "infoBallonMessage": to.Ptr("Rule2 InfoBalloon Message"), - // "metricDisplayName": to.Ptr("Available Memory Bytes"), - // }, - // RuleArmTemplate: &armalertsmanagement.RuleArmTemplate{ - // Schema: to.Ptr("https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#"), - // ContentVersion: to.Ptr("1.0.0.0"), - // Parameters: map[string]any{ - // "actionGroupIds":map[string]any{ - // "type": "array", - // "defaultValue":[]any{ - // }, - // "metadata":map[string]any{ - // "description": "Insert Action groups ids to attach them to the below alert rules.", - // }, - // }, - // "alertName":map[string]any{ - // "type": "string", - // "defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('targetResourceName'))]", - // "metadata":map[string]any{ - // "description": "Name of the alert rule", - // }, - // "minLength": float64(1), - // }, - // "alertNamePrefix":map[string]any{ - // "type": "string", - // "defaultValue": "Available Memory Bytes", - // "metadata":map[string]any{ - // "description": "prefix of the alert rule name", - // }, - // "minLength": float64(1), - // }, - // "alertSeverity":map[string]any{ - // "type": "int", - // "allowedValues":[]any{ - // float64(0), - // float64(1), - // float64(2), - // float64(3), - // float64(4), - // }, - // "defaultValue": float64(3), - // "metadata":map[string]any{ - // "description": "Severity of alert {0,1,2,3,4}", - // }, - // }, - // "targetResourceId":map[string]any{ - // "type": "string", - // "defaultValue": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourcegroups/test/providers/Microsoft.Compute/virtualMachines/testMachineCanBeSafelyDeleted", - // }, - // "targetResourceName":map[string]any{ - // "type": "string", - // "defaultValue": "testmachinecanbesafelydeleted", - // }, - // "threshold":map[string]any{ - // "type": "int", - // "defaultValue": float64(1000000000), - // "metadata":map[string]any{ - // "description": "The threshold value at which the alert is activated.", - // }, - // }, - // }, - // Resources: []any{ - // map[string]any{ - // "name": "[parameters('alertName')]", - // "type": "Microsoft.Insights/metricAlerts", - // "apiVersion": "2018-03-01", - // "location": "global", - // "properties":map[string]any{ - // "description": "Available Memory Bytes is less than 1 GB", - // "actions": "[variables('actionsForMetricAlerts')]", - // "criteria":map[string]any{ - // "allOf":[]any{ - // map[string]any{ - // "name": "Metric1", - // "metricName": "Available Memory Bytes", - // "operator": "LessThan", - // "threshold": "[parameters('threshold')]", - // "timeAggregation": "Average", - // }, - // }, - // "odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", - // }, - // "enabled": true, - // "evaluationFrequency": "PT5M", - // "scopes": "[variables('scopes')]", - // "severity": "[parameters('alertSeverity')]", - // "windowSize": "PT5M", - // }, - // }}, - // Variables: map[string]any{ - // "copy":[]any{ - // map[string]any{ - // "name": "actionsForMetricAlerts", - // "count": "[length(parameters('actionGroupIds'))]", - // "input":map[string]any{ - // "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForMetricAlerts')]]", - // }, - // }, - // }, - // "scopes": "[array(parameters('targetResourceId'))]", - // }, - // }, - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/6d2438481021a94793b07b226df06d5f3c61d51d/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-01-01-preview/examples/AlertRuleRecommendations_GetBySubscription_MAC.json -func ExampleAlertRuleRecommendationsClient_NewListByTargetTypePager_listAlertRuleRecommendationsForMonitoringAccountsAtSubscriptionLevel() { - 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.NewAlertRuleRecommendationsClient().NewListByTargetTypePager("microsoft.monitor/accounts", 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.AlertRuleRecommendationsListResponse = armalertsmanagement.AlertRuleRecommendationsListResponse{ - // Value: []*armalertsmanagement.AlertRuleRecommendationResource{ - // { - // Name: to.Ptr("NodeRecordingRulesRuleGroup"), - // Type: to.Ptr("Microsoft.AlertsManagement/alertRuleRecommendations"), - // ID: to.Ptr("/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/providers/Microsoft.AlertsManagement/alertRuleRecommendations/NodeRecordingRulesRuleGroup"), - // Properties: &armalertsmanagement.AlertRuleRecommendationProperties{ - // AlertRuleType: to.Ptr("Microsoft.AlertsManagement/prometheusRuleGroups"), - // DisplayInformation: map[string]*string{ - // "ruleInfo": to.Ptr("Rule Information for first recording rule."), - // }, - // RuleArmTemplate: &armalertsmanagement.RuleArmTemplate{ - // Schema: to.Ptr("https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#"), - // ContentVersion: to.Ptr("1.0.0.0"), - // Parameters: map[string]any{ - // "actionGroupIds":map[string]any{ - // "type": "array", - // "defaultValue":[]any{ - // }, - // "metadata":map[string]any{ - // "description": "Insert Action groups ids to attach them to the below alert rules.", - // }, - // }, - // "alertName":map[string]any{ - // "type": "string", - // "defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('clusterNameForPrometheus'))]", - // "metadata":map[string]any{ - // "description": "Name of the alert rule", - // }, - // "minLength": float64(1), - // }, - // "alertNamePrefix":map[string]any{ - // "type": "string", - // "defaultValue": "NodeRecordingRulesRuleGroup", - // "metadata":map[string]any{ - // "description": "prefix of the alert rule name", - // }, - // "minLength": float64(1), - // }, - // "clusterNameForPrometheus":map[string]any{ - // "type": "string", - // }, - // "location":map[string]any{ - // "type": "string", - // }, - // "targetResourceId":map[string]any{ - // "type": "string", - // }, - // "targetResourceName":map[string]any{ - // "type": "string", - // }, - // }, - // Resources: []any{ - // map[string]any{ - // "name": "[parameters('alertName')]", - // "type": "Microsoft.AlertsManagement/prometheusRuleGroups", - // "apiVersion": "2021-07-22-preview", - // "location": "[parameters('location')]", - // "properties":map[string]any{ - // "description": "Node Recording Rules RuleGroup", - // "clusterName": "[parameters('clusterNameForPrometheus')]", - // "interval": "PT1M", - // "rules":[]any{ - // map[string]any{ - // "expression": "count without (cpu, mode) ( node_cpu_seconds_total{job=\"node\",mode=\"idle\"})", - // "record": "instance:node_num_cpu:sum", - // }, - // }, - // "scopes": "[variables('scopes')]", - // }, - // }}, - // Variables: map[string]any{ - // "copy":[]any{ - // map[string]any{ - // "name": "actionsForPrometheusRuleGroups", - // "count": "[length(parameters('actionGroupIds'))]", - // "input":map[string]any{ - // "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForPrometheusRuleGroups')]]", - // }, - // }, - // }, - // "scopes": "[array(parameters('targetResourceId'))]", - // }, - // }, - // }, - // }, - // { - // Name: to.Ptr("KubernetesReccordingRulesRuleGroup"), - // Type: to.Ptr("Microsoft.AlertsManagement/alertRuleRecommendations"), - // ID: to.Ptr("/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/providers/Microsoft.AlertsManagement/alertRuleRecommendations/KubernetesReccordingRulesRuleGroup"), - // Properties: &armalertsmanagement.AlertRuleRecommendationProperties{ - // AlertRuleType: to.Ptr("Microsoft.AlertsManagement/prometheusRuleGroups"), - // DisplayInformation: map[string]*string{ - // "ruleInfo": to.Ptr("Rule Information for second recording rule."), - // }, - // RuleArmTemplate: &armalertsmanagement.RuleArmTemplate{ - // Schema: to.Ptr("https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#"), - // ContentVersion: to.Ptr("1.0.0.0"), - // Parameters: map[string]any{ - // "actionGroupIds":map[string]any{ - // "type": "array", - // "defaultValue":[]any{ - // }, - // "metadata":map[string]any{ - // "description": "Insert Action groups ids to attach them to the below alert rules.", - // }, - // }, - // "alertName":map[string]any{ - // "type": "string", - // "defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('clusterNameForPrometheus'))]", - // "metadata":map[string]any{ - // "description": "Name of the alert rule", - // }, - // "minLength": float64(1), - // }, - // "alertNamePrefix":map[string]any{ - // "type": "string", - // "defaultValue": "KubernetesReccordingRulesRuleGroup", - // "metadata":map[string]any{ - // "description": "prefix of the alert rule name", - // }, - // "minLength": float64(1), - // }, - // "clusterNameForPrometheus":map[string]any{ - // "type": "string", - // }, - // "location":map[string]any{ - // "type": "string", - // }, - // "targetResourceId":map[string]any{ - // "type": "string", - // }, - // "targetResourceName":map[string]any{ - // "type": "string", - // }, - // }, - // Resources: []any{ - // map[string]any{ - // "name": "[parameters('alertName')]", - // "type": "Microsoft.AlertsManagement/prometheusRuleGroups", - // "apiVersion": "2021-07-22-preview", - // "location": "[parameters('location')]", - // "properties":map[string]any{ - // "description": "Kubernetes Recording Rules RuleGroup", - // "clusterName": "[parameters('clusterNameForPrometheus')]", - // "interval": "PT1M", - // "rules":[]any{ - // map[string]any{ - // "expression": "sum by (cluster, namespace, pod, container) ( irate(container_cpu_usage_seconds_total{job=\"cadvisor\", image!=\"\"}[5m])) * on (cluster, namespace, pod) group_left(node) topk by (cluster, namespace, pod) ( 1, max by(cluster, namespace, pod, node) (kube_pod_info{node!=\"\"}))", - // "record": "node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate", - // }, - // }, - // "scopes": "[variables('scopes')]", - // }, - // }}, - // Variables: map[string]any{ - // "copy":[]any{ - // map[string]any{ - // "name": "actionsForPrometheusRuleGroups", - // "count": "[length(parameters('actionGroupIds'))]", - // "input":map[string]any{ - // "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForPrometheusRuleGroups')]]", - // }, - // }, - // }, - // "scopes": "[array(parameters('targetResourceId'))]", - // }, - // }, - // }, - // }, - // { - // Name: to.Ptr("KubernetesAlert-DefaultAlerts"), - // Type: to.Ptr("Microsoft.AlertsManagement/alertRuleRecommendations"), - // ID: to.Ptr("/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/providers/Microsoft.AlertsManagement/alertRuleRecommendations/KubernetesAlert-DefaultAlerts"), - // Properties: &armalertsmanagement.AlertRuleRecommendationProperties{ - // AlertRuleType: to.Ptr("Microsoft.AlertsManagement/prometheusRuleGroups"), - // DisplayInformation: map[string]*string{ - // "ruleInfo": to.Ptr("Rule Information for alerting rule."), - // }, - // RuleArmTemplate: &armalertsmanagement.RuleArmTemplate{ - // Schema: to.Ptr("https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#"), - // ContentVersion: to.Ptr("1.0.0.0"), - // Parameters: map[string]any{ - // "actionGroupIds":map[string]any{ - // "type": "array", - // "defaultValue":[]any{ - // }, - // "metadata":map[string]any{ - // "description": "Insert Action groups ids to attach them to the below alert rules.", - // }, - // }, - // "alertName":map[string]any{ - // "type": "string", - // "defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('clusterNameForPrometheus'))]", - // "metadata":map[string]any{ - // "description": "Name of the alert rule", - // }, - // "minLength": float64(1), - // }, - // "alertNamePrefix":map[string]any{ - // "type": "string", - // "defaultValue": "KubernetesAlert-DefaultAlerts", - // "metadata":map[string]any{ - // "description": "prefix of the alert rule name", - // }, - // "minLength": float64(1), - // }, - // "clusterNameForPrometheus":map[string]any{ - // "type": "string", - // }, - // "location":map[string]any{ - // "type": "string", - // }, - // "targetResourceId":map[string]any{ - // "type": "string", - // }, - // "targetResourceName":map[string]any{ - // "type": "string", - // }, - // }, - // Resources: []any{ - // map[string]any{ - // "name": "[parameters('alertName')]", - // "type": "Microsoft.AlertsManagement/prometheusRuleGroups", - // "apiVersion": "2021-07-22-preview", - // "location": "[parameters('location')]", - // "properties":map[string]any{ - // "description": "Kubernetes Alert RuleGroup-DefaultAlerts", - // "clusterName": "[parameters('clusterNameForPrometheus')]", - // "interval": "PT1M", - // "rules":[]any{ - // map[string]any{ - // "Severity": float64(3), - // "actions": "[variables('actionsForPrometheusRuleGroups')]", - // "alert": "KubePodCrashLooping", - // "expression": "max_over_time(kube_pod_container_status_waiting_reason{reason=\"CrashLoopBackOff\", job=\"kube-state-metrics\"}[5m]) >= 1", - // "for": "PT15M", - // "labels":map[string]any{ - // "severity": "warning", - // }, - // }, - // map[string]any{ - // "Severity": float64(3), - // "actions": "[variables('actionsForPrometheusRuleGroups')]", - // "alert": "KubePodNotReady", - // "expression": "sum by (namespace, pod, cluster) ( max by(namespace, pod, cluster) ( kube_pod_status_phase{job=\"kube-state-metrics\", phase=~\"Pending|Unknown\"} ) * on(namespace, pod, cluster) group_left(owner_kind) topk by(namespace, pod, cluster) ( 1, max by(namespace, pod, owner_kind, cluster) (kube_pod_owner{owner_kind!=\"Job\"}) )) > 0", - // "for": "PT15M", - // "labels":map[string]any{ - // "severity": "warning", - // }, - // }, - // }, - // "scopes": "[variables('scopes')]", - // }, - // }}, - // Variables: map[string]any{ - // "copy":[]any{ - // map[string]any{ - // "name": "actionsForPrometheusRuleGroups", - // "count": "[length(parameters('actionGroupIds'))]", - // "input":map[string]any{ - // "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForPrometheusRuleGroups')]]", - // }, - // }, - // }, - // "scopes": "[array(parameters('targetResourceId'))]", - // }, - // }, - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/6d2438481021a94793b07b226df06d5f3c61d51d/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-01-01-preview/examples/AlertRuleRecommendations_GetBySubscription_VM.json -func ExampleAlertRuleRecommendationsClient_NewListByTargetTypePager_listAlertRuleRecommendationsForVirtualMachinesAtSubscriptionLevel() { - 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.NewAlertRuleRecommendationsClient().NewListByTargetTypePager("microsoft.compute/virtualmachines", 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.AlertRuleRecommendationsListResponse = armalertsmanagement.AlertRuleRecommendationsListResponse{ - // Value: []*armalertsmanagement.AlertRuleRecommendationResource{ - // { - // Name: to.Ptr("Percentage CPU"), - // Type: to.Ptr("Microsoft.AlertsManagement/alertRuleRecommendations"), - // ID: to.Ptr("/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/providers/Microsoft.AlertsManagement/alertRuleRecommendations/Percentage CPU"), - // Properties: &armalertsmanagement.AlertRuleRecommendationProperties{ - // AlertRuleType: to.Ptr("Microsoft.Insights/metricAlerts"), - // DisplayInformation: map[string]*string{ - // "displayUnits": to.Ptr("Percentage"), - // "infoBallonLink": to.Ptr("Rule1 InfoBalloon Link"), - // "infoBallonMessage": to.Ptr("Rule1 InfoBalloon Message"), - // "metricDisplayName": to.Ptr("Percentage CPU"), - // }, - // RuleArmTemplate: &armalertsmanagement.RuleArmTemplate{ - // Schema: to.Ptr("https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#"), - // ContentVersion: to.Ptr("1.0.0.0"), - // Parameters: map[string]any{ - // "actionGroupIds":map[string]any{ - // "type": "array", - // "defaultValue":[]any{ - // }, - // "metadata":map[string]any{ - // "description": "Insert Action groups ids to attach them to the below alert rules.", - // }, - // }, - // "alertName":map[string]any{ - // "type": "string", - // "defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('targetResourceName'))]", - // "metadata":map[string]any{ - // "description": "Name of the alert rule", - // }, - // "minLength": float64(1), - // }, - // "alertNamePrefix":map[string]any{ - // "type": "string", - // "defaultValue": "Percentage CPU", - // "metadata":map[string]any{ - // "description": "prefix of the alert rule name", - // }, - // "minLength": float64(1), - // }, - // "alertSeverity":map[string]any{ - // "type": "int", - // "allowedValues":[]any{ - // float64(0), - // float64(1), - // float64(2), - // float64(3), - // float64(4), - // }, - // "defaultValue": float64(3), - // "metadata":map[string]any{ - // "description": "Severity of alert {0,1,2,3,4}", - // }, - // }, - // "targetResourceId":map[string]any{ - // "type": "string", - // }, - // "targetResourceName":map[string]any{ - // "type": "string", - // }, - // "threshold":map[string]any{ - // "type": "int", - // "defaultValue": float64(80), - // "metadata":map[string]any{ - // "description": "The threshold value at which the alert is activated.", - // }, - // }, - // }, - // Resources: []any{ - // map[string]any{ - // "name": "[parameters('alertName')]", - // "type": "Microsoft.Insights/metricAlerts", - // "apiVersion": "2018-03-01", - // "location": "global", - // "properties":map[string]any{ - // "description": "Percentage CPU is greater than 80 %", - // "actions": "[variables('actionsForMetricAlerts')]", - // "criteria":map[string]any{ - // "allOf":[]any{ - // map[string]any{ - // "name": "Metric1", - // "metricName": "Percentage CPU", - // "operator": "GreaterThan", - // "threshold": "[parameters('threshold')]", - // "timeAggregation": "Average", - // }, - // }, - // "odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", - // }, - // "enabled": true, - // "evaluationFrequency": "PT5M", - // "scopes": "[variables('scopes')]", - // "severity": "[parameters('alertSeverity')]", - // "windowSize": "PT5M", - // }, - // }}, - // Variables: map[string]any{ - // "copy":[]any{ - // map[string]any{ - // "name": "actionsForMetricAlerts", - // "count": "[length(parameters('actionGroupIds'))]", - // "input":map[string]any{ - // "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForMetricAlerts')]]", - // }, - // }, - // }, - // "scopes": "[array(parameters('targetResourceId'))]", - // }, - // }, - // }, - // }, - // { - // Name: to.Ptr("Available Memory Bytes"), - // Type: to.Ptr("Microsoft.AlertsManagement/alertRuleRecommendations"), - // ID: to.Ptr("/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/providers/Microsoft.AlertsManagement/alertRuleRecommendations/Available Memory Bytes"), - // Properties: &armalertsmanagement.AlertRuleRecommendationProperties{ - // AlertRuleType: to.Ptr("Microsoft.Insights/metricAlerts"), - // DisplayInformation: map[string]*string{ - // "displayUnits": to.Ptr("Gigabytes"), - // "infoBallonLink": to.Ptr("Rule2 InfoBalloon Link"), - // "infoBallonMessage": to.Ptr("Rule2 InfoBalloon Message"), - // "metricDisplayName": to.Ptr("Available Memory Bytes"), - // }, - // RuleArmTemplate: &armalertsmanagement.RuleArmTemplate{ - // Schema: to.Ptr("https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#"), - // ContentVersion: to.Ptr("1.0.0.0"), - // Parameters: map[string]any{ - // "actionGroupIds":map[string]any{ - // "type": "array", - // "defaultValue":[]any{ - // }, - // "metadata":map[string]any{ - // "description": "Insert Action groups ids to attach them to the below alert rules.", - // }, - // }, - // "alertName":map[string]any{ - // "type": "string", - // "defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('targetResourceName'))]", - // "metadata":map[string]any{ - // "description": "Name of the alert rule", - // }, - // "minLength": float64(1), - // }, - // "alertNamePrefix":map[string]any{ - // "type": "string", - // "defaultValue": "Available Memory Bytes", - // "metadata":map[string]any{ - // "description": "prefix of the alert rule name", - // }, - // "minLength": float64(1), - // }, - // "alertSeverity":map[string]any{ - // "type": "int", - // "allowedValues":[]any{ - // float64(0), - // float64(1), - // float64(2), - // float64(3), - // float64(4), - // }, - // "defaultValue": float64(3), - // "metadata":map[string]any{ - // "description": "Severity of alert {0,1,2,3,4}", - // }, - // }, - // "targetResourceId":map[string]any{ - // "type": "string", - // }, - // "targetResourceName":map[string]any{ - // "type": "string", - // }, - // "threshold":map[string]any{ - // "type": "int", - // "defaultValue": float64(1000000000), - // "metadata":map[string]any{ - // "description": "The threshold value at which the alert is activated.", - // }, - // }, - // }, - // Resources: []any{ - // map[string]any{ - // "name": "[parameters('alertName')]", - // "type": "Microsoft.Insights/metricAlerts", - // "apiVersion": "2018-03-01", - // "location": "global", - // "properties":map[string]any{ - // "description": "Available Memory Bytes is less than 1 GB", - // "actions": "[variables('actionsForMetricAlerts')]", - // "criteria":map[string]any{ - // "allOf":[]any{ - // map[string]any{ - // "name": "Metric1", - // "metricName": "Available Memory Bytes", - // "operator": "LessThan", - // "threshold": "[parameters('threshold')]", - // "timeAggregation": "Average", - // }, - // }, - // "odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", - // }, - // "enabled": true, - // "evaluationFrequency": "PT5M", - // "scopes": "[variables('scopes')]", - // "severity": "[parameters('alertSeverity')]", - // "windowSize": "PT5M", - // }, - // }}, - // Variables: map[string]any{ - // "copy":[]any{ - // map[string]any{ - // "name": "actionsForMetricAlerts", - // "count": "[length(parameters('actionGroupIds'))]", - // "input":map[string]any{ - // "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForMetricAlerts')]]", - // }, - // }, - // }, - // "scopes": "[array(parameters('targetResourceId'))]", - // }, - // }, - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alerts_client.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alerts_client.go index 7243f1edb8e2..372e3673c0ba 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alerts_client.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alerts_client.go @@ -1,6 +1,3 @@ -//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. @@ -24,22 +21,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 +41,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 2024-01-01-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 +69,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 +81,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", "2024-01-01-preview") reqQP.Set("newState", string(newState)) req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} @@ -115,9 +107,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 2024-01-01-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 +122,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 +134,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 @@ -158,7 +148,7 @@ func (client *AlertsClient) getAllCreateRequest(ctx context.Context, options *Al if options != nil && options.AlertState != nil { reqQP.Set("alertState", string(*options.AlertState)) } - reqQP.Set("api-version", "2019-05-05-preview") + reqQP.Set("api-version", "2024-01-01-preview") if options != nil && options.CustomTimeRange != nil { reqQP.Set("customTimeRange", *options.CustomTimeRange) } @@ -221,16 +211,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 2024-01-01-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 +238,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, _ *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 +250,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", "2024-01-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -277,20 +265,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 2024-01-01-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, _ *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", "2024-01-01-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 2024-01-01-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 +353,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, _ *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 +365,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", "2024-01-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -341,17 +384,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 2024-01-01-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 +412,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 @@ -385,7 +426,7 @@ func (client *AlertsClient) getSummaryCreateRequest(ctx context.Context, groupby if options != nil && options.AlertState != nil { reqQP.Set("alertState", string(*options.AlertState)) } - reqQP.Set("api-version", "2019-05-05-preview") + reqQP.Set("api-version", "2024-01-01-preview") if options != nil && options.CustomTimeRange != nil { reqQP.Set("customTimeRange", *options.CustomTimeRange) } @@ -428,10 +469,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 2024-01-01-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, _ *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", "2024-01-01-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 2024-01-01-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) { @@ -457,14 +557,14 @@ func (client *AlertsClient) MetaData(ctx context.Context, identifier Identifier, } // metaDataCreateRequest creates the MetaData request. -func (client *AlertsClient) metaDataCreateRequest(ctx context.Context, identifier Identifier, options *AlertsClientMetaDataOptions) (*policy.Request, error) { +func (client *AlertsClient) metaDataCreateRequest(ctx context.Context, identifier Identifier, _ *AlertsClientMetaDataOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.AlertsManagement/alertsMetaData" 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", "2019-05-05-preview") + reqQP.Set("api-version", "2024-01-01-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 45f93ca982a6..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/6d2438481021a94793b07b226df06d5f3c61d51d/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/6d2438481021a94793b07b226df06d5f3c61d51d/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/6d2438481021a94793b07b226df06d5f3c61d51d/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/6d2438481021a94793b07b226df06d5f3c61d51d/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/6d2438481021a94793b07b226df06d5f3c61d51d/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/6d2438481021a94793b07b226df06d5f3c61d51d/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 70b84c5f69bc..5fab1164980f 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/autorest.md +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/autorest.md @@ -5,11 +5,10 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/6d2438481021a94793b07b226df06d5f3c61d51d/specification/alertsmanagement/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/6d2438481021a94793b07b226df06d5f3c61d51d/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.10.0 +module-version: 0.11.0 modelerfour: lenient-model-deduplication: true -tag: package-2021-08 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/client.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/client.go new file mode 100644 index 000000000000..bab032eb483e --- /dev/null +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/client.go @@ -0,0 +1,99 @@ +// 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" +) + +// Client contains the methods for the AlertsManagementClient group. +// Don't use this type directly, use NewClient() instead. +type Client struct { + internal *arm.Client + subscriptionID string +} + +// NewClient creates a new instance of Client 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 NewClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*Client, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &Client{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// PreviewAlertRule - Retrieves the results of a simulated historical execution of an alert rule +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +// - parameters - The alert rule to preview. +// - options - ClientPreviewAlertRuleOptions contains the optional parameters for the Client.PreviewAlertRule method. +func (client *Client) PreviewAlertRule(ctx context.Context, parameters PreviewAlertRuleRequest, options *ClientPreviewAlertRuleOptions) (ClientPreviewAlertRuleResponse, error) { + var err error + const operationName = "Client.PreviewAlertRule" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.previewAlertRuleCreateRequest(ctx, parameters, options) + if err != nil { + return ClientPreviewAlertRuleResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ClientPreviewAlertRuleResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClientPreviewAlertRuleResponse{}, err + } + resp, err := client.previewAlertRuleHandleResponse(httpResp) + return resp, err +} + +// previewAlertRuleCreateRequest creates the PreviewAlertRule request. +func (client *Client) previewAlertRuleCreateRequest(ctx context.Context, parameters PreviewAlertRuleRequest, _ *ClientPreviewAlertRuleOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/previewAlertRule" + 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.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-05-01-preview") + 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 +} + +// previewAlertRuleHandleResponse handles the PreviewAlertRule response. +func (client *Client) previewAlertRuleHandleResponse(resp *http.Response) (ClientPreviewAlertRuleResponse, error) { + result := ClientPreviewAlertRuleResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PreviewAlertRuleResponse); err != nil { + return ClientPreviewAlertRuleResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/client_factory.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/client_factory.go index 0bff9358535f..78c7f3c2e6e9 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/client_factory.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/client_factory.go @@ -1,6 +1,3 @@ -//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. @@ -17,21 +14,24 @@ import ( // Don't use this type directly, use NewClientFactory instead. type ClientFactory struct { subscriptionID string + issueName string internal *arm.Client } // NewClientFactory creates a new instance of ClientFactory with the specified values. // The parameter values will be propagated to any client created from this factory. // - subscriptionID - The ID of the target subscription. +// - issueName - The name of the IssueResource // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. -func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { +func NewClientFactory(subscriptionID string, issueName string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } return &ClientFactory{ subscriptionID: subscriptionID, + issueName: issueName, internal: internal, }, nil } @@ -55,11 +55,26 @@ func (c *ClientFactory) NewAlertRuleRecommendationsClient() *AlertRuleRecommenda // NewAlertsClient creates a new instance of AlertsClient. func (c *ClientFactory) NewAlertsClient() *AlertsClient { return &AlertsClient{ + internal: c.internal, + } +} + +// NewClient creates a new instance of Client. +func (c *ClientFactory) NewClient() *Client { + return &Client{ subscriptionID: c.subscriptionID, internal: c.internal, } } +// NewIssueClient creates a new instance of IssueClient. +func (c *ClientFactory) NewIssueClient() *IssueClient { + return &IssueClient{ + issueName: c.issueName, + internal: c.internal, + } +} + // NewOperationsClient creates a new instance of OperationsClient. func (c *ClientFactory) NewOperationsClient() *OperationsClient { return &OperationsClient{ @@ -82,10 +97,3 @@ func (c *ClientFactory) NewSmartGroupsClient() *SmartGroupsClient { internal: c.internal, } } - -// NewTenantActivityLogAlertsClient creates a new instance of TenantActivityLogAlertsClient. -func (c *ClientFactory) NewTenantActivityLogAlertsClient() *TenantActivityLogAlertsClient { - return &TenantActivityLogAlertsClient{ - internal: c.internal, - } -} diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/constants.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/constants.go index 488ee7e08b12..ddf2576496ad 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/constants.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/constants.go @@ -1,6 +1,3 @@ -//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. @@ -10,9 +7,30 @@ package armalertsmanagement const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/alertsmanagement/armalertsmanagement" - moduleVersion = "v0.10.0" + moduleVersion = "v0.11.0" +) + +// AbnormalEventType - The type of the abnormal event +type AbnormalEventType string + +const ( + // AbnormalEventTypeDependency - The abnormal event type is a dependency + AbnormalEventTypeDependency AbnormalEventType = "Dependency" + // AbnormalEventTypeException - The abnormal event type is an exception + AbnormalEventTypeException AbnormalEventType = "Exception" + // AbnormalEventTypeRequest - The abnormal event type is a request + AbnormalEventTypeRequest AbnormalEventType = "Request" ) +// PossibleAbnormalEventTypeValues returns the possible values for the AbnormalEventType const type. +func PossibleAbnormalEventTypeValues() []AbnormalEventType { + return []AbnormalEventType{ + AbnormalEventTypeDependency, + AbnormalEventTypeException, + AbnormalEventTypeRequest, + } +} + // ActionType - Action that should be applied. type ActionType string @@ -29,6 +47,57 @@ func PossibleActionTypeValues() []ActionType { } } +// AddedByType - The type of entity that added data to the issue +type AddedByType string + +const ( + // AddedByTypeAutomatic - The data was added automatically + AddedByTypeAutomatic AddedByType = "Automatic" + // AddedByTypeManual - The data was added manually by a user + AddedByTypeManual AddedByType = "Manual" +) + +// PossibleAddedByTypeValues returns the possible values for the AddedByType const type. +func PossibleAddedByTypeValues() []AddedByType { + return []AddedByType{ + AddedByTypeAutomatic, + AddedByTypeManual, + } +} + +// AggregationType - The aggregation type of the metric +type AggregationType string + +const ( + // AggregationTypeAverage - The metric aggregation type is average + AggregationTypeAverage AggregationType = "Average" + // AggregationTypeCount - The metric aggregation type is count + AggregationTypeCount AggregationType = "Count" + // AggregationTypeMaximum - The metric aggregation type is maximum + AggregationTypeMaximum AggregationType = "Maximum" + // AggregationTypeMinimum - The metric aggregation type is minimum + AggregationTypeMinimum AggregationType = "Minimum" + // AggregationTypeNone - There is no aggregation type + AggregationTypeNone AggregationType = "None" + // AggregationTypeTotal - The metric aggregation type is total + AggregationTypeTotal AggregationType = "Total" + // AggregationTypeUnique - The metric aggregation type is unique, used for logs + AggregationTypeUnique AggregationType = "Unique" +) + +// PossibleAggregationTypeValues returns the possible values for the AggregationType const type. +func PossibleAggregationTypeValues() []AggregationType { + return []AggregationType{ + AggregationTypeAverage, + AggregationTypeCount, + AggregationTypeMaximum, + AggregationTypeMinimum, + AggregationTypeNone, + AggregationTypeTotal, + AggregationTypeUnique, + } +} + // AlertModificationEvent - Reason for the modification type AlertModificationEvent string @@ -59,12 +128,40 @@ func PossibleAlertModificationEventValues() []AlertModificationEvent { } } +// AlertSeverity - Severity of the alert. Should be an integer between [0-4]. Value of 0 is severest. Relevant and required +// only for rules of the kind LogAlert. +type AlertSeverity int64 + +const ( + AlertSeverityFour AlertSeverity = 4 + AlertSeverityOne AlertSeverity = 1 + AlertSeverityThree AlertSeverity = 3 + AlertSeverityTwo AlertSeverity = 2 + AlertSeverityZero AlertSeverity = 0 +) + +// PossibleAlertSeverityValues returns the possible values for the AlertSeverity const type. +func PossibleAlertSeverityValues() []AlertSeverity { + return []AlertSeverity{ + AlertSeverityFour, + AlertSeverityOne, + AlertSeverityThree, + AlertSeverityTwo, + AlertSeverityZero, + } +} + type AlertState string const ( AlertStateAcknowledged AlertState = "Acknowledged" AlertStateClosed AlertState = "Closed" + AlertStateFired AlertState = "Fired" + AlertStateFiring AlertState = "Firing" AlertStateNew AlertState = "New" + AlertStateNoAlert AlertState = "NoAlert" + AlertStateResolved AlertState = "Resolved" + AlertStateResolving AlertState = "Resolving" ) // PossibleAlertStateValues returns the possible values for the AlertState const type. @@ -72,7 +169,12 @@ func PossibleAlertStateValues() []AlertState { return []AlertState{ AlertStateAcknowledged, AlertStateClosed, + AlertStateFired, + AlertStateFiring, AlertStateNew, + AlertStateNoAlert, + AlertStateResolved, + AlertStateResolving, } } @@ -130,6 +232,108 @@ func PossibleAlertsSummaryGroupByFieldsValues() []AlertsSummaryGroupByFields { } } +// AnomalyDirection - The direction of the anomaly +type AnomalyDirection string + +const ( + // AnomalyDirectionDecrease - The anomaly direction is decreasing + AnomalyDirectionDecrease AnomalyDirection = "Decrease" + // AnomalyDirectionIncrease - The anomaly direction is increasing + AnomalyDirectionIncrease AnomalyDirection = "Increase" + // AnomalyDirectionIncreaseAndDecrease - The anomaly direction is both increasing and decreasing + AnomalyDirectionIncreaseAndDecrease AnomalyDirection = "IncreaseAndDecrease" +) + +// PossibleAnomalyDirectionValues returns the possible values for the AnomalyDirection const type. +func PossibleAnomalyDirectionValues() []AnomalyDirection { + return []AnomalyDirection{ + AnomalyDirectionDecrease, + AnomalyDirectionIncrease, + AnomalyDirectionIncreaseAndDecrease, + } +} + +// AvailabilityState - Represents the health state of a resource +type AvailabilityState string + +const ( + // AvailabilityStateAvailable - The resource is available + AvailabilityStateAvailable AvailabilityState = "Available" + // AvailabilityStateDegraded - The resource is degraded + AvailabilityStateDegraded AvailabilityState = "Degraded" + // AvailabilityStateUnavailable - The resource is unavailable + AvailabilityStateUnavailable AvailabilityState = "Unavailable" + // AvailabilityStateUnknown - The availability state of the resource is unknown + AvailabilityStateUnknown AvailabilityState = "Unknown" + // AvailabilityStateUserInitiated - The user initiated this state change + AvailabilityStateUserInitiated AvailabilityState = "UserInitiated" +) + +// PossibleAvailabilityStateValues returns the possible values for the AvailabilityState const type. +func PossibleAvailabilityStateValues() []AvailabilityState { + return []AvailabilityState{ + AvailabilityStateAvailable, + AvailabilityStateDegraded, + AvailabilityStateUnavailable, + AvailabilityStateUnknown, + AvailabilityStateUserInitiated, + } +} + +// CategoryType - The category type +type CategoryType string + +const ( + // CategoryTypeAlert - The category is for an alert + CategoryTypeAlert CategoryType = "Alert" + // CategoryTypeDiagnostics - The category is for diagnostics + CategoryTypeDiagnostics CategoryType = "Diagnostics" + // CategoryTypeInvestigation - The category is for an investigation + CategoryTypeInvestigation CategoryType = "Investigation" + // CategoryTypeLog - The category is for a log + CategoryTypeLog CategoryType = "Log" + // CategoryTypeMetric - The category is for a metric + CategoryTypeMetric CategoryType = "Metric" + // CategoryTypeResourceHealth - The category is for resource health + CategoryTypeResourceHealth CategoryType = "ResourceHealth" +) + +// PossibleCategoryTypeValues returns the possible values for the CategoryType const type. +func PossibleCategoryTypeValues() []CategoryType { + return []CategoryType{ + CategoryTypeAlert, + CategoryTypeDiagnostics, + CategoryTypeInvestigation, + CategoryTypeLog, + CategoryTypeMetric, + CategoryTypeResourceHealth, + } +} + +// ConditionOperator - The criteria operator. Relevant and required only for rules of the kind LogAlert. +type ConditionOperator string + +const ( + ConditionOperatorEquals ConditionOperator = "Equals" + ConditionOperatorGreaterOrLessThan ConditionOperator = "GreaterOrLessThan" + ConditionOperatorGreaterThan ConditionOperator = "GreaterThan" + ConditionOperatorGreaterThanOrEqual ConditionOperator = "GreaterThanOrEqual" + ConditionOperatorLessThan ConditionOperator = "LessThan" + ConditionOperatorLessThanOrEqual ConditionOperator = "LessThanOrEqual" +) + +// PossibleConditionOperatorValues returns the possible values for the ConditionOperator const type. +func PossibleConditionOperatorValues() []ConditionOperator { + return []ConditionOperator{ + ConditionOperatorEquals, + ConditionOperatorGreaterOrLessThan, + ConditionOperatorGreaterThan, + ConditionOperatorGreaterThanOrEqual, + ConditionOperatorLessThan, + ConditionOperatorLessThanOrEqual, + } +} + // CreatedByType - The type of identity that created the resource. type CreatedByType string @@ -150,6 +354,22 @@ func PossibleCreatedByTypeValues() []CreatedByType { } } +// CriterionType - Specifies the type of threshold criteria +type CriterionType string + +const ( + CriterionTypeDynamicThresholdCriterion CriterionType = "DynamicThresholdCriterion" + CriterionTypeStaticThresholdCriterion CriterionType = "StaticThresholdCriterion" +) + +// PossibleCriterionTypeValues returns the possible values for the CriterionType const type. +func PossibleCriterionTypeValues() []CriterionType { + return []CriterionType{ + CriterionTypeDynamicThresholdCriterion, + CriterionTypeStaticThresholdCriterion, + } +} + // DaysOfWeek - Days of week. type DaysOfWeek string @@ -176,6 +396,55 @@ func PossibleDaysOfWeekValues() []DaysOfWeek { } } +// DetailsType - The details type +type DetailsType string + +const ( + // DetailsTypeAbnormalEvent - The details is for a abnormal event + DetailsTypeAbnormalEvent DetailsType = "AbnormalEvent" + // DetailsTypeAzureMetric - The details is for an azure metric + DetailsTypeAzureMetric DetailsType = "AzureMetric" + // DetailsTypeDiagnostics - The details for diagnostics + DetailsTypeDiagnostics DetailsType = "Diagnostics" + // DetailsTypeFinding - The details is for a finding + DetailsTypeFinding DetailsType = "Finding" + // DetailsTypeInvestigation - The details is for an investigation + DetailsTypeInvestigation DetailsType = "Investigation" + // DetailsTypeRelatedAlert - The details is for a related alert + DetailsTypeRelatedAlert DetailsType = "RelatedAlert" + // DetailsTypeResourceHealth - The details is for resource health + DetailsTypeResourceHealth DetailsType = "ResourceHealth" +) + +// PossibleDetailsTypeValues returns the possible values for the DetailsType const type. +func PossibleDetailsTypeValues() []DetailsType { + return []DetailsType{ + DetailsTypeAbnormalEvent, + DetailsTypeAzureMetric, + DetailsTypeDiagnostics, + DetailsTypeFinding, + DetailsTypeInvestigation, + DetailsTypeRelatedAlert, + DetailsTypeResourceHealth, + } +} + +// DimensionOperator - Operator for dimension values +type DimensionOperator string + +const ( + DimensionOperatorExclude DimensionOperator = "Exclude" + DimensionOperatorInclude DimensionOperator = "Include" +) + +// PossibleDimensionOperatorValues returns the possible values for the DimensionOperator const type. +func PossibleDimensionOperatorValues() []DimensionOperator { + return []DimensionOperator{ + DimensionOperatorExclude, + DimensionOperatorInclude, + } +} + // Field - Field for a given condition. type Field string @@ -210,6 +479,27 @@ func PossibleFieldValues() []Field { } } +// HealthState - The health state of the investigation result +type HealthState string + +const ( + // HealthStateHealthy - The result is healthy + HealthStateHealthy HealthState = "Healthy" + // HealthStateUnhealthy - The result is unhealthy + HealthStateUnhealthy HealthState = "Unhealthy" + // HealthStateUnknown - The health state of the result is unknown + HealthStateUnknown HealthState = "Unknown" +) + +// PossibleHealthStateValues returns the possible values for the HealthState const type. +func PossibleHealthStateValues() []HealthState { + return []HealthState{ + HealthStateHealthy, + HealthStateUnhealthy, + HealthStateUnknown, + } +} + type Identifier string const ( @@ -223,6 +513,72 @@ func PossibleIdentifierValues() []Identifier { } } +// InvestigationEntityType - The type of the investigation entity +type InvestigationEntityType string + +const ( + // InvestigationEntityTypeEvidence - Evidence entity + InvestigationEntityTypeEvidence InvestigationEntityType = "Evidence" + // InvestigationEntityTypeFinding - Finding entity + InvestigationEntityTypeFinding InvestigationEntityType = "Finding" + // InvestigationEntityTypeInvestigation - Investigation entity + InvestigationEntityTypeInvestigation InvestigationEntityType = "Investigation" +) + +// PossibleInvestigationEntityTypeValues returns the possible values for the InvestigationEntityType const type. +func PossibleInvestigationEntityTypeValues() []InvestigationEntityType { + return []InvestigationEntityType{ + InvestigationEntityTypeEvidence, + InvestigationEntityTypeFinding, + InvestigationEntityTypeInvestigation, + } +} + +// InvestigationExecutionRunState - The execution state of the investigation +type InvestigationExecutionRunState string + +const ( + // InvestigationExecutionRunStateCanceled - The investigation execution was canceled + InvestigationExecutionRunStateCanceled InvestigationExecutionRunState = "Canceled" + // InvestigationExecutionRunStateFailed - The investigation execution failed + InvestigationExecutionRunStateFailed InvestigationExecutionRunState = "Failed" + // InvestigationExecutionRunStateInProgress - The investigation execution is in progress + InvestigationExecutionRunStateInProgress InvestigationExecutionRunState = "InProgress" + // InvestigationExecutionRunStateNone - The investigation execution didn't start + InvestigationExecutionRunStateNone InvestigationExecutionRunState = "None" + // InvestigationExecutionRunStateSucceeded - The investigation execution completed successfully + InvestigationExecutionRunStateSucceeded InvestigationExecutionRunState = "Succeeded" +) + +// PossibleInvestigationExecutionRunStateValues returns the possible values for the InvestigationExecutionRunState const type. +func PossibleInvestigationExecutionRunStateValues() []InvestigationExecutionRunState { + return []InvestigationExecutionRunState{ + InvestigationExecutionRunStateCanceled, + InvestigationExecutionRunStateFailed, + InvestigationExecutionRunStateInProgress, + InvestigationExecutionRunStateNone, + InvestigationExecutionRunStateSucceeded, + } +} + +// Kind - Indicates the type of scheduled query rule. The default is LogAlert. +type Kind string + +const ( + KindEventLogAlert Kind = "EventLogAlert" + KindLogAlert Kind = "LogAlert" + KindLogToMetric Kind = "LogToMetric" +) + +// PossibleKindValues returns the possible values for the Kind const type. +func PossibleKindValues() []Kind { + return []Kind{ + KindEventLogAlert, + KindLogAlert, + KindLogToMetric, + } +} + // MetadataIdentifier - Identification of the information to be retrieved by API call type MetadataIdentifier string @@ -264,6 +620,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 +640,7 @@ func PossibleMonitorServiceValues() []MonitorService { MonitorServiceLogAnalytics, MonitorServiceNagios, MonitorServicePlatform, + MonitorServiceResourceHealth, MonitorServiceSCOM, MonitorServiceServiceHealth, MonitorServiceSmartDetector, @@ -329,6 +687,48 @@ func PossibleRecurrenceTypeValues() []RecurrenceType { } } +// Relevance - The relevance status of the resource +type Relevance string + +const ( + // RelevanceIrrelevant - The resource is irrelevant to the issue + RelevanceIrrelevant Relevance = "Irrelevant" + // RelevanceNone - No relevance status for the resource + RelevanceNone Relevance = "None" + // RelevanceRelevant - The resource is relevant to the issue + RelevanceRelevant Relevance = "Relevant" +) + +// PossibleRelevanceValues returns the possible values for the Relevance const type. +func PossibleRelevanceValues() []Relevance { + return []Relevance{ + RelevanceIrrelevant, + RelevanceNone, + RelevanceRelevant, + } +} + +// ResourceProvisioningState - The provisioning state of a resource type. +type ResourceProvisioningState string + +const ( + // ResourceProvisioningStateCanceled - Resource creation was canceled. + ResourceProvisioningStateCanceled ResourceProvisioningState = "Canceled" + // ResourceProvisioningStateFailed - Resource creation failed. + ResourceProvisioningStateFailed ResourceProvisioningState = "Failed" + // ResourceProvisioningStateSucceeded - Resource has been created. + ResourceProvisioningStateSucceeded ResourceProvisioningState = "Succeeded" +) + +// PossibleResourceProvisioningStateValues returns the possible values for the ResourceProvisioningState const type. +func PossibleResourceProvisioningStateValues() []ResourceProvisioningState { + return []ResourceProvisioningState{ + ResourceProvisioningStateCanceled, + ResourceProvisioningStateFailed, + ResourceProvisioningStateSucceeded, + } +} + type Severity string const ( @@ -442,6 +842,54 @@ func PossibleStateValues() []State { } } +// Status - The status of the evaluation of the enrichment. +type Status string + +const ( + StatusCanceled Status = "Canceled" + StatusClosed Status = "Closed" + StatusFailed Status = "Failed" + StatusInProgress Status = "InProgress" + StatusMitigated Status = "Mitigated" + StatusNew Status = "New" + StatusSucceeded Status = "Succeeded" +) + +// PossibleStatusValues returns the possible values for the Status const type. +func PossibleStatusValues() []Status { + return []Status{ + StatusCanceled, + StatusClosed, + StatusFailed, + StatusInProgress, + StatusMitigated, + StatusNew, + StatusSucceeded, + } +} + +// TimeAggregation - Aggregation type. Relevant and required only for rules of the kind LogAlert. +type TimeAggregation string + +const ( + TimeAggregationAverage TimeAggregation = "Average" + TimeAggregationCount TimeAggregation = "Count" + TimeAggregationMaximum TimeAggregation = "Maximum" + TimeAggregationMinimum TimeAggregation = "Minimum" + TimeAggregationTotal TimeAggregation = "Total" +) + +// PossibleTimeAggregationValues returns the possible values for the TimeAggregation const type. +func PossibleTimeAggregationValues() []TimeAggregation { + return []TimeAggregation{ + TimeAggregationAverage, + TimeAggregationCount, + TimeAggregationMaximum, + TimeAggregationMinimum, + TimeAggregationTotal, + } +} + type TimeRange string const ( @@ -460,3 +908,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/alertprocessingrules_server.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/alertprocessingrules_server.go index 5088049302eb..4adefe3c2c77 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/alertprocessingrules_server.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/alertprocessingrules_server.go @@ -1,6 +1,3 @@ -//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. @@ -76,31 +73,50 @@ func (a *AlertProcessingRulesServerTransport) Do(req *http.Request) (*http.Respo return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return a.dispatchToMethodFake(req, method) +} - switch method { - case "AlertProcessingRulesClient.CreateOrUpdate": - resp, err = a.dispatchCreateOrUpdate(req) - case "AlertProcessingRulesClient.Delete": - resp, err = a.dispatchDelete(req) - case "AlertProcessingRulesClient.GetByName": - resp, err = a.dispatchGetByName(req) - case "AlertProcessingRulesClient.NewListByResourceGroupPager": - resp, err = a.dispatchNewListByResourceGroupPager(req) - case "AlertProcessingRulesClient.NewListBySubscriptionPager": - resp, err = a.dispatchNewListBySubscriptionPager(req) - case "AlertProcessingRulesClient.Update": - resp, err = a.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (a *AlertProcessingRulesServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if alertProcessingRulesServerTransportInterceptor != nil { + res.resp, res.err, intercepted = alertProcessingRulesServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "AlertProcessingRulesClient.CreateOrUpdate": + res.resp, res.err = a.dispatchCreateOrUpdate(req) + case "AlertProcessingRulesClient.Delete": + res.resp, res.err = a.dispatchDelete(req) + case "AlertProcessingRulesClient.GetByName": + res.resp, res.err = a.dispatchGetByName(req) + case "AlertProcessingRulesClient.NewListByResourceGroupPager": + res.resp, res.err = a.dispatchNewListByResourceGroupPager(req) + case "AlertProcessingRulesClient.NewListBySubscriptionPager": + res.resp, res.err = a.dispatchNewListBySubscriptionPager(req) + case "AlertProcessingRulesClient.Update": + res.resp, res.err = a.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (a *AlertProcessingRulesServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -324,3 +340,9 @@ func (a *AlertProcessingRulesServerTransport) dispatchUpdate(req *http.Request) } return resp, nil } + +// set this to conditionally intercept incoming requests to AlertProcessingRulesServerTransport +var alertProcessingRulesServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/alertrulerecommendations_server.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/alertrulerecommendations_server.go index eabf2dfcfc7e..eb5dbcfaaf9d 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/alertrulerecommendations_server.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/alertrulerecommendations_server.go @@ -1,6 +1,3 @@ -//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. @@ -59,23 +56,42 @@ func (a *AlertRuleRecommendationsServerTransport) Do(req *http.Request) (*http.R return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return a.dispatchToMethodFake(req, method) +} - 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) - } +func (a *AlertRuleRecommendationsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if alertRuleRecommendationsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = alertRuleRecommendationsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "AlertRuleRecommendationsClient.NewListByResourcePager": + res.resp, res.err = a.dispatchNewListByResourcePager(req) + case "AlertRuleRecommendationsClient.NewListByTargetTypePager": + res.resp, res.err = a.dispatchNewListByTargetTypePager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (a *AlertRuleRecommendationsServerTransport) dispatchNewListByResourcePager(req *http.Request) (*http.Response, error) { @@ -152,3 +168,9 @@ func (a *AlertRuleRecommendationsServerTransport) dispatchNewListByTargetTypePag } return resp, nil } + +// set this to conditionally intercept incoming requests to AlertRuleRecommendationsServerTransport +var alertRuleRecommendationsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/alerts_server.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/alerts_server.go index 2a5f81089ff9..3135f3384a99 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/alerts_server.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/alerts_server.go @@ -1,6 +1,3 @@ -//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. @@ -28,23 +25,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 +61,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. @@ -76,38 +83,61 @@ func (a *AlertsServerTransport) Do(req *http.Request) (*http.Response, error) { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return a.dispatchToMethodFake(req, method) +} - switch method { - case "AlertsClient.ChangeState": - resp, err = a.dispatchChangeState(req) - case "AlertsClient.NewGetAllPager": - resp, err = a.dispatchNewGetAllPager(req) - case "AlertsClient.GetByID": - resp, err = a.dispatchGetByID(req) - case "AlertsClient.GetHistory": - resp, err = a.dispatchGetHistory(req) - case "AlertsClient.GetSummary": - resp, err = a.dispatchGetSummary(req) - case "AlertsClient.MetaData": - resp, err = a.dispatchMetaData(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (a *AlertsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if alertsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = alertsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "AlertsClient.ChangeState": + res.resp, res.err = a.dispatchChangeState(req) + case "AlertsClient.NewGetAllPager": + res.resp, res.err = a.dispatchNewGetAllPager(req) + case "AlertsClient.GetByID": + res.resp, res.err = a.dispatchGetByID(req) + case "AlertsClient.GetEnrichments": + res.resp, res.err = a.dispatchGetEnrichments(req) + case "AlertsClient.GetHistory": + res.resp, res.err = a.dispatchGetHistory(req) + case "AlertsClient.GetSummary": + res.resp, res.err = a.dispatchGetSummary(req) + case "AlertsClient.NewListEnrichmentsPager": + res.resp, res.err = a.dispatchNewListEnrichmentsPager(req) + case "AlertsClient.MetaData": + res.resp, res.err = a.dispatchMetaData(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (a *AlertsServerTransport) dispatchChangeState(req *http.Request) (*http.Response, error) { 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 { @@ -118,6 +148,10 @@ func (a *AlertsServerTransport) dispatchChangeState(req *http.Request) (*http.Re if err != nil { return nil, err } + 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 @@ -138,7 +172,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 +193,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 +326,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 +351,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 +380,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 +450,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 +545,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 +560,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")} @@ -506,3 +627,9 @@ func (a *AlertsServerTransport) dispatchMetaData(req *http.Request) (*http.Respo } return resp, nil } + +// set this to conditionally intercept incoming requests to AlertsServerTransport +var alertsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/internal.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/internal.go index 72f540f217a1..d186c1b38a18 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/internal.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/internal.go @@ -1,6 +1,3 @@ -//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. @@ -15,6 +12,11 @@ import ( "sync" ) +type result struct { + resp *http.Response + err error +} + type nonRetriableError struct { error } diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/issue_server.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/issue_server.go new file mode 100644 index 000000000000..360d4eded77e --- /dev/null +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/issue_server.go @@ -0,0 +1,533 @@ +// 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/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/alertsmanagement/armalertsmanagement" + "net/http" + "net/url" + "regexp" +) + +// IssueServer is a fake server for instances of the armalertsmanagement.IssueClient type. +type IssueServer struct { + // AddOrUpdateAlerts is the fake for method IssueClient.AddOrUpdateAlerts + // HTTP status codes to indicate success: http.StatusOK + AddOrUpdateAlerts func(ctx context.Context, resourceURI string, body armalertsmanagement.RelatedAlerts, options *armalertsmanagement.IssueClientAddOrUpdateAlertsOptions) (resp azfake.Responder[armalertsmanagement.IssueClientAddOrUpdateAlertsResponse], errResp azfake.ErrorResponder) + + // AddOrUpdateResources is the fake for method IssueClient.AddOrUpdateResources + // HTTP status codes to indicate success: http.StatusOK + AddOrUpdateResources func(ctx context.Context, resourceURI string, body armalertsmanagement.RelatedResources, options *armalertsmanagement.IssueClientAddOrUpdateResourcesOptions) (resp azfake.Responder[armalertsmanagement.IssueClientAddOrUpdateResourcesResponse], errResp azfake.ErrorResponder) + + // Create is the fake for method IssueClient.Create + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + Create func(ctx context.Context, resourceURI string, resource armalertsmanagement.IssueResource, options *armalertsmanagement.IssueClientCreateOptions) (resp azfake.Responder[armalertsmanagement.IssueClientCreateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method IssueClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceURI string, options *armalertsmanagement.IssueClientDeleteOptions) (resp azfake.Responder[armalertsmanagement.IssueClientDeleteResponse], errResp azfake.ErrorResponder) + + // FetchInvestigationResult is the fake for method IssueClient.FetchInvestigationResult + // HTTP status codes to indicate success: http.StatusOK + FetchInvestigationResult func(ctx context.Context, resourceURI string, body armalertsmanagement.FetchInvestigationResultParameters, options *armalertsmanagement.IssueClientFetchInvestigationResultOptions) (resp azfake.Responder[armalertsmanagement.IssueClientFetchInvestigationResultResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method IssueClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceURI string, options *armalertsmanagement.IssueClientGetOptions) (resp azfake.Responder[armalertsmanagement.IssueClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method IssueClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceURI string, options *armalertsmanagement.IssueClientListOptions) (resp azfake.PagerResponder[armalertsmanagement.IssueClientListResponse]) + + // NewListAlertsPager is the fake for method IssueClient.NewListAlertsPager + // HTTP status codes to indicate success: http.StatusOK + NewListAlertsPager func(resourceURI string, body armalertsmanagement.ListParameter, options *armalertsmanagement.IssueClientListAlertsOptions) (resp azfake.PagerResponder[armalertsmanagement.IssueClientListAlertsResponse]) + + // NewListResourcesPager is the fake for method IssueClient.NewListResourcesPager + // HTTP status codes to indicate success: http.StatusOK + NewListResourcesPager func(resourceURI string, body armalertsmanagement.ListParameter, options *armalertsmanagement.IssueClientListResourcesOptions) (resp azfake.PagerResponder[armalertsmanagement.IssueClientListResourcesResponse]) + + // StartInvestigation is the fake for method IssueClient.StartInvestigation + // HTTP status codes to indicate success: http.StatusOK + StartInvestigation func(ctx context.Context, resourceURI string, body armalertsmanagement.StartInvestigationParameters, options *armalertsmanagement.IssueClientStartInvestigationOptions) (resp azfake.Responder[armalertsmanagement.IssueClientStartInvestigationResponse], errResp azfake.ErrorResponder) + + // Update is the fake for method IssueClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceURI string, properties armalertsmanagement.IssueResourceUpdate, options *armalertsmanagement.IssueClientUpdateOptions) (resp azfake.Responder[armalertsmanagement.IssueClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewIssueServerTransport creates a new instance of IssueServerTransport with the provided implementation. +// The returned IssueServerTransport instance is connected to an instance of armalertsmanagement.IssueClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewIssueServerTransport(srv *IssueServer) *IssueServerTransport { + return &IssueServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armalertsmanagement.IssueClientListResponse]](), + newListAlertsPager: newTracker[azfake.PagerResponder[armalertsmanagement.IssueClientListAlertsResponse]](), + newListResourcesPager: newTracker[azfake.PagerResponder[armalertsmanagement.IssueClientListResourcesResponse]](), + } +} + +// IssueServerTransport connects instances of armalertsmanagement.IssueClient to instances of IssueServer. +// Don't use this type directly, use NewIssueServerTransport instead. +type IssueServerTransport struct { + srv *IssueServer + newListPager *tracker[azfake.PagerResponder[armalertsmanagement.IssueClientListResponse]] + newListAlertsPager *tracker[azfake.PagerResponder[armalertsmanagement.IssueClientListAlertsResponse]] + newListResourcesPager *tracker[azfake.PagerResponder[armalertsmanagement.IssueClientListResourcesResponse]] +} + +// Do implements the policy.Transporter interface for IssueServerTransport. +func (i *IssueServerTransport) 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")} + } + + return i.dispatchToMethodFake(req, method) +} + +func (i *IssueServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if issueServerTransportInterceptor != nil { + res.resp, res.err, intercepted = issueServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "IssueClient.AddOrUpdateAlerts": + res.resp, res.err = i.dispatchAddOrUpdateAlerts(req) + case "IssueClient.AddOrUpdateResources": + res.resp, res.err = i.dispatchAddOrUpdateResources(req) + case "IssueClient.Create": + res.resp, res.err = i.dispatchCreate(req) + case "IssueClient.Delete": + res.resp, res.err = i.dispatchDelete(req) + case "IssueClient.FetchInvestigationResult": + res.resp, res.err = i.dispatchFetchInvestigationResult(req) + case "IssueClient.Get": + res.resp, res.err = i.dispatchGet(req) + case "IssueClient.NewListPager": + res.resp, res.err = i.dispatchNewListPager(req) + case "IssueClient.NewListAlertsPager": + res.resp, res.err = i.dispatchNewListAlertsPager(req) + case "IssueClient.NewListResourcesPager": + res.resp, res.err = i.dispatchNewListResourcesPager(req) + case "IssueClient.StartInvestigation": + res.resp, res.err = i.dispatchStartInvestigation(req) + case "IssueClient.Update": + res.resp, res.err = i.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (i *IssueServerTransport) dispatchAddOrUpdateAlerts(req *http.Request) (*http.Response, error) { + if i.srv.AddOrUpdateAlerts == nil { + return nil, &nonRetriableError{errors.New("fake for method AddOrUpdateAlerts not implemented")} + } + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AlertsManagement/issues/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/addOrUpdateAlerts` + 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) + } + body, err := server.UnmarshalRequestAsJSON[armalertsmanagement.RelatedAlerts](req) + if err != nil { + return nil, err + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.AddOrUpdateAlerts(req.Context(), resourceURIParam, 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).RelatedAlerts, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IssueServerTransport) dispatchAddOrUpdateResources(req *http.Request) (*http.Response, error) { + if i.srv.AddOrUpdateResources == nil { + return nil, &nonRetriableError{errors.New("fake for method AddOrUpdateResources not implemented")} + } + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AlertsManagement/issues/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/addOrUpdateResources` + 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) + } + body, err := server.UnmarshalRequestAsJSON[armalertsmanagement.RelatedResources](req) + if err != nil { + return nil, err + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.AddOrUpdateResources(req.Context(), resourceURIParam, 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).RelatedResources, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IssueServerTransport) dispatchCreate(req *http.Request) (*http.Response, error) { + if i.srv.Create == nil { + return nil, &nonRetriableError{errors.New("fake for method Create not implemented")} + } + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AlertsManagement/issues/(?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) + } + body, err := server.UnmarshalRequestAsJSON[armalertsmanagement.IssueResource](req) + if err != nil { + return nil, err + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.Create(req.Context(), resourceURIParam, 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).IssueResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IssueServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if i.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AlertsManagement/issues/(?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) + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.Delete(req.Context(), resourceURIParam, 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 (i *IssueServerTransport) dispatchFetchInvestigationResult(req *http.Request) (*http.Response, error) { + if i.srv.FetchInvestigationResult == nil { + return nil, &nonRetriableError{errors.New("fake for method FetchInvestigationResult not implemented")} + } + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AlertsManagement/issues/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/fetchInvestigationResult` + 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) + } + body, err := server.UnmarshalRequestAsJSON[armalertsmanagement.FetchInvestigationResultParameters](req) + if err != nil { + return nil, err + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.FetchInvestigationResult(req.Context(), resourceURIParam, 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).InvestigationResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IssueServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if i.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AlertsManagement/issues/(?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) + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.Get(req.Context(), resourceURIParam, 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).IssueResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IssueServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if i.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := i.newListPager.get(req) + if newListPager == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AlertsManagement/issues` + 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 := i.srv.NewListPager(resourceURIParam, nil) + newListPager = &resp + i.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armalertsmanagement.IssueClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + i.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + i.newListPager.remove(req) + } + return resp, nil +} + +func (i *IssueServerTransport) dispatchNewListAlertsPager(req *http.Request) (*http.Response, error) { + if i.srv.NewListAlertsPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListAlertsPager not implemented")} + } + newListAlertsPager := i.newListAlertsPager.get(req) + if newListAlertsPager == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AlertsManagement/issues/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listAlerts` + 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) + } + body, err := server.UnmarshalRequestAsJSON[armalertsmanagement.ListParameter](req) + if err != nil { + return nil, err + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + resp := i.srv.NewListAlertsPager(resourceURIParam, body, nil) + newListAlertsPager = &resp + i.newListAlertsPager.add(req, newListAlertsPager) + server.PagerResponderInjectNextLinks(newListAlertsPager, req, func(page *armalertsmanagement.IssueClientListAlertsResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListAlertsPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + i.newListAlertsPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListAlertsPager) { + i.newListAlertsPager.remove(req) + } + return resp, nil +} + +func (i *IssueServerTransport) dispatchNewListResourcesPager(req *http.Request) (*http.Response, error) { + if i.srv.NewListResourcesPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListResourcesPager not implemented")} + } + newListResourcesPager := i.newListResourcesPager.get(req) + if newListResourcesPager == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AlertsManagement/issues/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listResources` + 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) + } + body, err := server.UnmarshalRequestAsJSON[armalertsmanagement.ListParameter](req) + if err != nil { + return nil, err + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + resp := i.srv.NewListResourcesPager(resourceURIParam, body, nil) + newListResourcesPager = &resp + i.newListResourcesPager.add(req, newListResourcesPager) + server.PagerResponderInjectNextLinks(newListResourcesPager, req, func(page *armalertsmanagement.IssueClientListResourcesResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListResourcesPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + i.newListResourcesPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListResourcesPager) { + i.newListResourcesPager.remove(req) + } + return resp, nil +} + +func (i *IssueServerTransport) dispatchStartInvestigation(req *http.Request) (*http.Response, error) { + if i.srv.StartInvestigation == nil { + return nil, &nonRetriableError{errors.New("fake for method StartInvestigation not implemented")} + } + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AlertsManagement/issues/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/startInvestigation` + 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) + } + body, err := server.UnmarshalRequestAsJSON[armalertsmanagement.StartInvestigationParameters](req) + if err != nil { + return nil, err + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.StartInvestigation(req.Context(), resourceURIParam, 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).InvestigationMetadata, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IssueServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if i.srv.Update == nil { + return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} + } + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AlertsManagement/issues/(?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) + } + body, err := server.UnmarshalRequestAsJSON[armalertsmanagement.IssueResourceUpdate](req) + if err != nil { + return nil, err + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.Update(req.Context(), resourceURIParam, 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).IssueResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to IssueServerTransport +var issueServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/operations_server.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/operations_server.go index 8df4ab0c0394..3cc469f8689c 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/operations_server.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/operations_server.go @@ -1,6 +1,3 @@ -//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. @@ -51,21 +48,40 @@ func (o *OperationsServerTransport) Do(req *http.Request) (*http.Response, error return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return o.dispatchToMethodFake(req, method) +} - switch method { - case "OperationsClient.NewListPager": - resp, err = o.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (o *OperationsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if operationsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = operationsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "OperationsClient.NewListPager": + res.resp, res.err = o.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { @@ -94,3 +110,9 @@ func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*ht } return resp, nil } + +// set this to conditionally intercept incoming requests to OperationsServerTransport +var operationsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/prometheusrulegroups_server.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/prometheusrulegroups_server.go index 941e6607cf3a..9e42622f2a47 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/prometheusrulegroups_server.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/prometheusrulegroups_server.go @@ -1,6 +1,3 @@ -//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. @@ -45,7 +42,7 @@ type PrometheusRuleGroupsServer struct { // 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.PrometheusRuleGroupResourcePatch, options *armalertsmanagement.PrometheusRuleGroupsClientUpdateOptions) (resp azfake.Responder[armalertsmanagement.PrometheusRuleGroupsClientUpdateResponse], errResp azfake.ErrorResponder) + 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. @@ -75,31 +72,50 @@ func (p *PrometheusRuleGroupsServerTransport) Do(req *http.Request) (*http.Respo return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return p.dispatchToMethodFake(req, method) +} - 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) - } +func (p *PrometheusRuleGroupsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if prometheusRuleGroupsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = prometheusRuleGroupsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "PrometheusRuleGroupsClient.CreateOrUpdate": + res.resp, res.err = p.dispatchCreateOrUpdate(req) + case "PrometheusRuleGroupsClient.Delete": + res.resp, res.err = p.dispatchDelete(req) + case "PrometheusRuleGroupsClient.Get": + res.resp, res.err = p.dispatchGet(req) + case "PrometheusRuleGroupsClient.NewListByResourceGroupPager": + res.resp, res.err = p.dispatchNewListByResourceGroupPager(req) + case "PrometheusRuleGroupsClient.NewListBySubscriptionPager": + res.resp, res.err = p.dispatchNewListBySubscriptionPager(req) + case "PrometheusRuleGroupsClient.Update": + res.resp, res.err = p.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (p *PrometheusRuleGroupsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -279,7 +295,7 @@ func (p *PrometheusRuleGroupsServerTransport) dispatchUpdate(req *http.Request) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - body, err := server.UnmarshalRequestAsJSON[armalertsmanagement.PrometheusRuleGroupResourcePatch](req) + body, err := server.UnmarshalRequestAsJSON[armalertsmanagement.PrometheusRuleGroupResourcePatchParameters](req) if err != nil { return nil, err } @@ -305,3 +321,9 @@ func (p *PrometheusRuleGroupsServerTransport) dispatchUpdate(req *http.Request) } return resp, nil } + +// set this to conditionally intercept incoming requests to PrometheusRuleGroupsServerTransport +var prometheusRuleGroupsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/server.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/server.go new file mode 100644 index 000000000000..48dfe70b9e65 --- /dev/null +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/server.go @@ -0,0 +1,117 @@ +// 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" + "regexp" +) + +// Server is a fake server for instances of the armalertsmanagement.Client type. +type Server struct { + // PreviewAlertRule is the fake for method Client.PreviewAlertRule + // HTTP status codes to indicate success: http.StatusOK + PreviewAlertRule func(ctx context.Context, parameters armalertsmanagement.PreviewAlertRuleRequest, options *armalertsmanagement.ClientPreviewAlertRuleOptions) (resp azfake.Responder[armalertsmanagement.ClientPreviewAlertRuleResponse], errResp azfake.ErrorResponder) +} + +// NewServerTransport creates a new instance of ServerTransport with the provided implementation. +// The returned ServerTransport instance is connected to an instance of armalertsmanagement.Client via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewServerTransport(srv *Server) *ServerTransport { + return &ServerTransport{srv: srv} +} + +// ServerTransport connects instances of armalertsmanagement.Client to instances of Server. +// Don't use this type directly, use NewServerTransport instead. +type ServerTransport struct { + srv *Server +} + +// Do implements the policy.Transporter interface for ServerTransport. +func (s *ServerTransport) 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")} + } + + return s.dispatchToMethodFake(req, method) +} + +func (s *ServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if serverTransportInterceptor != nil { + res.resp, res.err, intercepted = serverTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "Client.PreviewAlertRule": + res.resp, res.err = s.dispatchPreviewAlertRule(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (s *ServerTransport) dispatchPreviewAlertRule(req *http.Request) (*http.Response, error) { + if s.srv.PreviewAlertRule == nil { + return nil, &nonRetriableError{errors.New("fake for method PreviewAlertRule not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AlertsManagement/previewAlertRule` + 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) + } + body, err := server.UnmarshalRequestAsJSON[armalertsmanagement.PreviewAlertRuleRequest](req) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.PreviewAlertRule(req.Context(), 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).PreviewAlertRuleResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to ServerTransport +var serverTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/server_factory.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/server_factory.go index ac9320b6a0a1..f7ca488187c9 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/server_factory.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/server_factory.go @@ -1,6 +1,3 @@ -//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. @@ -19,13 +16,29 @@ import ( // ServerFactory is a fake server for instances of the armalertsmanagement.ClientFactory type. type ServerFactory struct { - AlertProcessingRulesServer AlertProcessingRulesServer + // AlertProcessingRulesServer contains the fakes for client AlertProcessingRulesClient + AlertProcessingRulesServer AlertProcessingRulesServer + + // AlertRuleRecommendationsServer contains the fakes for client AlertRuleRecommendationsClient AlertRuleRecommendationsServer AlertRuleRecommendationsServer - AlertsServer AlertsServer - OperationsServer OperationsServer - PrometheusRuleGroupsServer PrometheusRuleGroupsServer - SmartGroupsServer SmartGroupsServer - TenantActivityLogAlertsServer TenantActivityLogAlertsServer + + // AlertsServer contains the fakes for client AlertsClient + AlertsServer AlertsServer + + // Server contains the fakes for client Client + Server Server + + // IssueServer contains the fakes for client IssueClient + IssueServer IssueServer + + // OperationsServer contains the fakes for client OperationsClient + OperationsServer OperationsServer + + // PrometheusRuleGroupsServer contains the fakes for client PrometheusRuleGroupsClient + PrometheusRuleGroupsServer PrometheusRuleGroupsServer + + // SmartGroupsServer contains the fakes for client SmartGroupsClient + SmartGroupsServer SmartGroupsServer } // NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. @@ -45,10 +58,11 @@ type ServerFactoryTransport struct { trAlertProcessingRulesServer *AlertProcessingRulesServerTransport trAlertRuleRecommendationsServer *AlertRuleRecommendationsServerTransport trAlertsServer *AlertsServerTransport + trServer *ServerTransport + trIssueServer *IssueServerTransport trOperationsServer *OperationsServerTransport trPrometheusRuleGroupsServer *PrometheusRuleGroupsServerTransport trSmartGroupsServer *SmartGroupsServerTransport - trTenantActivityLogAlertsServer *TenantActivityLogAlertsServerTransport } // Do implements the policy.Transporter interface for ServerFactoryTransport. @@ -77,6 +91,12 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { case "AlertsClient": initServer(s, &s.trAlertsServer, func() *AlertsServerTransport { return NewAlertsServerTransport(&s.srv.AlertsServer) }) resp, err = s.trAlertsServer.Do(req) + case "Client": + initServer(s, &s.trServer, func() *ServerTransport { return NewServerTransport(&s.srv.Server) }) + resp, err = s.trServer.Do(req) + case "IssueClient": + initServer(s, &s.trIssueServer, func() *IssueServerTransport { return NewIssueServerTransport(&s.srv.IssueServer) }) + resp, err = s.trIssueServer.Do(req) case "OperationsClient": initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) resp, err = s.trOperationsServer.Do(req) @@ -88,11 +108,6 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { case "SmartGroupsClient": initServer(s, &s.trSmartGroupsServer, func() *SmartGroupsServerTransport { return NewSmartGroupsServerTransport(&s.srv.SmartGroupsServer) }) resp, err = s.trSmartGroupsServer.Do(req) - case "TenantActivityLogAlertsClient": - initServer(s, &s.trTenantActivityLogAlertsServer, func() *TenantActivityLogAlertsServerTransport { - return NewTenantActivityLogAlertsServerTransport(&s.srv.TenantActivityLogAlertsServer) - }) - resp, err = s.trTenantActivityLogAlertsServer.Do(req) default: err = fmt.Errorf("unhandled client %s", client) } diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/smartgroups_server.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/smartgroups_server.go index 18daa0e15fd0..9f107c7d8d81 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/smartgroups_server.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/smartgroups_server.go @@ -1,6 +1,3 @@ -//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. @@ -67,27 +64,46 @@ func (s *SmartGroupsServerTransport) Do(req *http.Request) (*http.Response, erro return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return s.dispatchToMethodFake(req, method) +} - switch method { - case "SmartGroupsClient.ChangeState": - resp, err = s.dispatchChangeState(req) - case "SmartGroupsClient.NewGetAllPager": - resp, err = s.dispatchNewGetAllPager(req) - case "SmartGroupsClient.GetByID": - resp, err = s.dispatchGetByID(req) - case "SmartGroupsClient.GetHistory": - resp, err = s.dispatchGetHistory(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (s *SmartGroupsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if smartGroupsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = smartGroupsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "SmartGroupsClient.ChangeState": + res.resp, res.err = s.dispatchChangeState(req) + case "SmartGroupsClient.NewGetAllPager": + res.resp, res.err = s.dispatchNewGetAllPager(req) + case "SmartGroupsClient.GetByID": + res.resp, res.err = s.dispatchGetByID(req) + case "SmartGroupsClient.GetHistory": + res.resp, res.err = s.dispatchGetHistory(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (s *SmartGroupsServerTransport) dispatchChangeState(req *http.Request) (*http.Response, error) { @@ -307,3 +323,9 @@ func (s *SmartGroupsServerTransport) dispatchGetHistory(req *http.Request) (*htt } return resp, nil } + +// set this to conditionally intercept incoming requests to SmartGroupsServerTransport +var smartGroupsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/tenantactivitylogalerts_server.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/tenantactivitylogalerts_server.go deleted file mode 100644 index c41adceb5a50..000000000000 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/tenantactivitylogalerts_server.go +++ /dev/null @@ -1,308 +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. 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/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/alertsmanagement/armalertsmanagement" - "net/http" - "net/url" - "regexp" -) - -// TenantActivityLogAlertsServer is a fake server for instances of the armalertsmanagement.TenantActivityLogAlertsClient type. -type TenantActivityLogAlertsServer struct { - // CreateOrUpdate is the fake for method TenantActivityLogAlertsClient.CreateOrUpdate - // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - CreateOrUpdate func(ctx context.Context, managementGroupName string, alertRuleName string, tenantActivityLogAlertRule armalertsmanagement.TenantActivityLogAlertResource, options *armalertsmanagement.TenantActivityLogAlertsClientCreateOrUpdateOptions) (resp azfake.Responder[armalertsmanagement.TenantActivityLogAlertsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) - - // Delete is the fake for method TenantActivityLogAlertsClient.Delete - // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent - Delete func(ctx context.Context, managementGroupName string, alertRuleName string, options *armalertsmanagement.TenantActivityLogAlertsClientDeleteOptions) (resp azfake.Responder[armalertsmanagement.TenantActivityLogAlertsClientDeleteResponse], errResp azfake.ErrorResponder) - - // Get is the fake for method TenantActivityLogAlertsClient.Get - // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, managementGroupName string, alertRuleName string, options *armalertsmanagement.TenantActivityLogAlertsClientGetOptions) (resp azfake.Responder[armalertsmanagement.TenantActivityLogAlertsClientGetResponse], errResp azfake.ErrorResponder) - - // NewListByManagementGroupPager is the fake for method TenantActivityLogAlertsClient.NewListByManagementGroupPager - // HTTP status codes to indicate success: http.StatusOK - NewListByManagementGroupPager func(managementGroupName string, options *armalertsmanagement.TenantActivityLogAlertsClientListByManagementGroupOptions) (resp azfake.PagerResponder[armalertsmanagement.TenantActivityLogAlertsClientListByManagementGroupResponse]) - - // NewListByTenantPager is the fake for method TenantActivityLogAlertsClient.NewListByTenantPager - // HTTP status codes to indicate success: http.StatusOK - NewListByTenantPager func(options *armalertsmanagement.TenantActivityLogAlertsClientListByTenantOptions) (resp azfake.PagerResponder[armalertsmanagement.TenantActivityLogAlertsClientListByTenantResponse]) - - // Update is the fake for method TenantActivityLogAlertsClient.Update - // HTTP status codes to indicate success: http.StatusOK - Update func(ctx context.Context, managementGroupName string, alertRuleName string, tenantActivityLogAlertRulePatch armalertsmanagement.TenantAlertRulePatchObject, options *armalertsmanagement.TenantActivityLogAlertsClientUpdateOptions) (resp azfake.Responder[armalertsmanagement.TenantActivityLogAlertsClientUpdateResponse], errResp azfake.ErrorResponder) -} - -// NewTenantActivityLogAlertsServerTransport creates a new instance of TenantActivityLogAlertsServerTransport with the provided implementation. -// The returned TenantActivityLogAlertsServerTransport instance is connected to an instance of armalertsmanagement.TenantActivityLogAlertsClient via the -// azcore.ClientOptions.Transporter field in the client's constructor parameters. -func NewTenantActivityLogAlertsServerTransport(srv *TenantActivityLogAlertsServer) *TenantActivityLogAlertsServerTransport { - return &TenantActivityLogAlertsServerTransport{ - srv: srv, - newListByManagementGroupPager: newTracker[azfake.PagerResponder[armalertsmanagement.TenantActivityLogAlertsClientListByManagementGroupResponse]](), - newListByTenantPager: newTracker[azfake.PagerResponder[armalertsmanagement.TenantActivityLogAlertsClientListByTenantResponse]](), - } -} - -// TenantActivityLogAlertsServerTransport connects instances of armalertsmanagement.TenantActivityLogAlertsClient to instances of TenantActivityLogAlertsServer. -// Don't use this type directly, use NewTenantActivityLogAlertsServerTransport instead. -type TenantActivityLogAlertsServerTransport struct { - srv *TenantActivityLogAlertsServer - newListByManagementGroupPager *tracker[azfake.PagerResponder[armalertsmanagement.TenantActivityLogAlertsClientListByManagementGroupResponse]] - newListByTenantPager *tracker[azfake.PagerResponder[armalertsmanagement.TenantActivityLogAlertsClientListByTenantResponse]] -} - -// Do implements the policy.Transporter interface for TenantActivityLogAlertsServerTransport. -func (t *TenantActivityLogAlertsServerTransport) 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 "TenantActivityLogAlertsClient.CreateOrUpdate": - resp, err = t.dispatchCreateOrUpdate(req) - case "TenantActivityLogAlertsClient.Delete": - resp, err = t.dispatchDelete(req) - case "TenantActivityLogAlertsClient.Get": - resp, err = t.dispatchGet(req) - case "TenantActivityLogAlertsClient.NewListByManagementGroupPager": - resp, err = t.dispatchNewListByManagementGroupPager(req) - case "TenantActivityLogAlertsClient.NewListByTenantPager": - resp, err = t.dispatchNewListByTenantPager(req) - case "TenantActivityLogAlertsClient.Update": - resp, err = t.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } - - if err != nil { - return nil, err - } - - return resp, nil -} - -func (t *TenantActivityLogAlertsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { - if t.srv.CreateOrUpdate == nil { - return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} - } - const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AlertsManagement/tenantActivityLogAlerts/(?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) - } - body, err := server.UnmarshalRequestAsJSON[armalertsmanagement.TenantActivityLogAlertResource](req) - if err != nil { - return nil, err - } - managementGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupName")]) - if err != nil { - return nil, err - } - alertRuleNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("alertRuleName")]) - if err != nil { - return nil, err - } - respr, errRespr := t.srv.CreateOrUpdate(req.Context(), managementGroupNameParam, alertRuleNameParam, 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).TenantActivityLogAlertResource, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (t *TenantActivityLogAlertsServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { - if t.srv.Delete == nil { - return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} - } - const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AlertsManagement/tenantActivityLogAlerts/(?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) - } - managementGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupName")]) - if err != nil { - return nil, err - } - alertRuleNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("alertRuleName")]) - if err != nil { - return nil, err - } - respr, errRespr := t.srv.Delete(req.Context(), managementGroupNameParam, alertRuleNameParam, 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 (t *TenantActivityLogAlertsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { - if t.srv.Get == nil { - return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} - } - const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AlertsManagement/tenantActivityLogAlerts/(?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) - } - managementGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupName")]) - if err != nil { - return nil, err - } - alertRuleNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("alertRuleName")]) - if err != nil { - return nil, err - } - respr, errRespr := t.srv.Get(req.Context(), managementGroupNameParam, alertRuleNameParam, 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).TenantActivityLogAlertResource, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (t *TenantActivityLogAlertsServerTransport) dispatchNewListByManagementGroupPager(req *http.Request) (*http.Response, error) { - if t.srv.NewListByManagementGroupPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListByManagementGroupPager not implemented")} - } - newListByManagementGroupPager := t.newListByManagementGroupPager.get(req) - if newListByManagementGroupPager == nil { - const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AlertsManagement/tenantActivityLogAlerts` - 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) - } - managementGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupName")]) - if err != nil { - return nil, err - } - resp := t.srv.NewListByManagementGroupPager(managementGroupNameParam, nil) - newListByManagementGroupPager = &resp - t.newListByManagementGroupPager.add(req, newListByManagementGroupPager) - server.PagerResponderInjectNextLinks(newListByManagementGroupPager, req, func(page *armalertsmanagement.TenantActivityLogAlertsClientListByManagementGroupResponse, createLink func() string) { - page.NextLink = to.Ptr(createLink()) - }) - } - resp, err := server.PagerResponderNext(newListByManagementGroupPager, req) - if err != nil { - return nil, err - } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - t.newListByManagementGroupPager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListByManagementGroupPager) { - t.newListByManagementGroupPager.remove(req) - } - return resp, nil -} - -func (t *TenantActivityLogAlertsServerTransport) dispatchNewListByTenantPager(req *http.Request) (*http.Response, error) { - if t.srv.NewListByTenantPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListByTenantPager not implemented")} - } - newListByTenantPager := t.newListByTenantPager.get(req) - if newListByTenantPager == nil { - resp := t.srv.NewListByTenantPager(nil) - newListByTenantPager = &resp - t.newListByTenantPager.add(req, newListByTenantPager) - server.PagerResponderInjectNextLinks(newListByTenantPager, req, func(page *armalertsmanagement.TenantActivityLogAlertsClientListByTenantResponse, createLink func() string) { - page.NextLink = to.Ptr(createLink()) - }) - } - resp, err := server.PagerResponderNext(newListByTenantPager, req) - if err != nil { - return nil, err - } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - t.newListByTenantPager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListByTenantPager) { - t.newListByTenantPager.remove(req) - } - return resp, nil -} - -func (t *TenantActivityLogAlertsServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { - if t.srv.Update == nil { - return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} - } - const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AlertsManagement/tenantActivityLogAlerts/(?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) - } - body, err := server.UnmarshalRequestAsJSON[armalertsmanagement.TenantAlertRulePatchObject](req) - if err != nil { - return nil, err - } - managementGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupName")]) - if err != nil { - return nil, err - } - alertRuleNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("alertRuleName")]) - if err != nil { - return nil, err - } - respr, errRespr := t.srv.Update(req.Context(), managementGroupNameParam, alertRuleNameParam, 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).TenantActivityLogAlertResource, req) - if err != nil { - return nil, err - } - return resp, nil -} diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/time_rfc3339.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/time_rfc3339.go deleted file mode 100644 index 81f308b0d343..000000000000 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/fake/time_rfc3339.go +++ /dev/null @@ -1,110 +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. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package fake - -import ( - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" - "regexp" - "strings" - "time" -) - -// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. -var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) - -const ( - utcDateTime = "2006-01-02T15:04:05.999999999" - utcDateTimeJSON = `"` + utcDateTime + `"` - utcDateTimeNoT = "2006-01-02 15:04:05.999999999" - utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` - dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` - dateTimeJSON = `"` + time.RFC3339Nano + `"` - dateTimeJSONNoT = `"` + dateTimeNoT + `"` -) - -type dateTimeRFC3339 time.Time - -func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { - tt := time.Time(t) - return tt.MarshalJSON() -} - -func (t dateTimeRFC3339) MarshalText() ([]byte, error) { - tt := time.Time(t) - return tt.MarshalText() -} - -func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { - tzOffset := tzOffsetRegex.Match(data) - hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") - var layout string - if tzOffset && hasT { - layout = dateTimeJSON - } else if tzOffset { - layout = dateTimeJSONNoT - } else if hasT { - layout = utcDateTimeJSON - } else { - layout = utcDateTimeJSONNoT - } - return t.Parse(layout, string(data)) -} - -func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { - tzOffset := tzOffsetRegex.Match(data) - hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") - var layout string - if tzOffset && hasT { - layout = time.RFC3339Nano - } else if tzOffset { - layout = dateTimeNoT - } else if hasT { - layout = utcDateTime - } else { - layout = utcDateTimeNoT - } - return t.Parse(layout, string(data)) -} - -func (t *dateTimeRFC3339) Parse(layout, value string) error { - p, err := time.Parse(layout, strings.ToUpper(value)) - *t = dateTimeRFC3339(p) - return err -} - -func (t dateTimeRFC3339) String() string { - return time.Time(t).Format(time.RFC3339Nano) -} - -func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { - if t == nil { - return - } else if azcore.IsNullValue(t) { - m[k] = nil - return - } else if reflect.ValueOf(t).IsNil() { - return - } - m[k] = (*dateTimeRFC3339)(t) -} - -func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || string(data) == "null" { - return nil - } - var aux dateTimeRFC3339 - if err := json.Unmarshal(data, &aux); err != nil { - return fmt.Errorf("struct field %s: %v", fn, err) - } - *t = (*time.Time)(&aux) - return nil -} diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/go.mod b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/go.mod index ae93659f9329..3dd6a7a2680c 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/go.mod +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/go.mod @@ -4,13 +4,13 @@ go 1.23.0 require ( github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2 github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.1 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3 v3.1.0 github.com/stretchr/testify v1.10.0 ) require ( + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2 // indirect github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.2.0 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2 // 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..e83f37248154 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/interfaces.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/interfaces.go @@ -1,6 +1,3 @@ -//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. @@ -17,6 +14,15 @@ type ActionClassification interface { 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 +32,26 @@ type AlertsMetaDataPropertiesClassification interface { GetAlertsMetaDataProperties() *AlertsMetaDataProperties } +// DetailsBaseClassification provides polymorphic access to related types. +// Call the interface's GetDetailsBase() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *AbnormalEventDetails, *AzureMetricDetails, *DetailsBase, *DiagnosticsSolutionDetails, *InvestigationDetails, *RelatedAlertDetails, +// - *ResourceHealthDetails +type DetailsBaseClassification interface { + // GetDetailsBase returns the DetailsBase content of the underlying type. + GetDetailsBase() *DetailsBase +} + +// 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/issue_client.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/issue_client.go new file mode 100644 index 000000000000..c7ea8443c8ed --- /dev/null +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/issue_client.go @@ -0,0 +1,678 @@ +// 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" +) + +// IssueClient contains the methods for the Issue group. +// Don't use this type directly, use NewIssueClient() instead. +type IssueClient struct { + internal *arm.Client + issueName string +} + +// NewIssueClient creates a new instance of IssueClient with the specified values. +// - issueName - The name of the IssueResource +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewIssueClient(issueName string, credential azcore.TokenCredential, options *arm.ClientOptions) (*IssueClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &IssueClient{ + issueName: issueName, + internal: cl, + } + return client, nil +} + +// AddOrUpdateAlerts - Add or update alerts in the issue +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-03-01-preview +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - body - The content of the action request +// - options - IssueClientAddOrUpdateAlertsOptions contains the optional parameters for the IssueClient.AddOrUpdateAlerts method. +func (client *IssueClient) AddOrUpdateAlerts(ctx context.Context, resourceURI string, body RelatedAlerts, options *IssueClientAddOrUpdateAlertsOptions) (IssueClientAddOrUpdateAlertsResponse, error) { + var err error + const operationName = "IssueClient.AddOrUpdateAlerts" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.addOrUpdateAlertsCreateRequest(ctx, resourceURI, body, options) + if err != nil { + return IssueClientAddOrUpdateAlertsResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return IssueClientAddOrUpdateAlertsResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return IssueClientAddOrUpdateAlertsResponse{}, err + } + resp, err := client.addOrUpdateAlertsHandleResponse(httpResp) + return resp, err +} + +// addOrUpdateAlertsCreateRequest creates the AddOrUpdateAlerts request. +func (client *IssueClient) addOrUpdateAlertsCreateRequest(ctx context.Context, resourceURI string, body RelatedAlerts, _ *IssueClientAddOrUpdateAlertsOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.AlertsManagement/issues/{issueName}/addOrUpdateAlerts" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if client.issueName == "" { + return nil, errors.New("parameter client.issueName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{issueName}", url.PathEscape(client.issueName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// addOrUpdateAlertsHandleResponse handles the AddOrUpdateAlerts response. +func (client *IssueClient) addOrUpdateAlertsHandleResponse(resp *http.Response) (IssueClientAddOrUpdateAlertsResponse, error) { + result := IssueClientAddOrUpdateAlertsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RelatedAlerts); err != nil { + return IssueClientAddOrUpdateAlertsResponse{}, err + } + return result, nil +} + +// AddOrUpdateResources - Add or update resources in the issue +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-03-01-preview +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - body - The content of the action request +// - options - IssueClientAddOrUpdateResourcesOptions contains the optional parameters for the IssueClient.AddOrUpdateResources +// method. +func (client *IssueClient) AddOrUpdateResources(ctx context.Context, resourceURI string, body RelatedResources, options *IssueClientAddOrUpdateResourcesOptions) (IssueClientAddOrUpdateResourcesResponse, error) { + var err error + const operationName = "IssueClient.AddOrUpdateResources" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.addOrUpdateResourcesCreateRequest(ctx, resourceURI, body, options) + if err != nil { + return IssueClientAddOrUpdateResourcesResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return IssueClientAddOrUpdateResourcesResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return IssueClientAddOrUpdateResourcesResponse{}, err + } + resp, err := client.addOrUpdateResourcesHandleResponse(httpResp) + return resp, err +} + +// addOrUpdateResourcesCreateRequest creates the AddOrUpdateResources request. +func (client *IssueClient) addOrUpdateResourcesCreateRequest(ctx context.Context, resourceURI string, body RelatedResources, _ *IssueClientAddOrUpdateResourcesOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.AlertsManagement/issues/{issueName}/addOrUpdateResources" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if client.issueName == "" { + return nil, errors.New("parameter client.issueName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{issueName}", url.PathEscape(client.issueName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// addOrUpdateResourcesHandleResponse handles the AddOrUpdateResources response. +func (client *IssueClient) addOrUpdateResourcesHandleResponse(resp *http.Response) (IssueClientAddOrUpdateResourcesResponse, error) { + result := IssueClientAddOrUpdateResourcesResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RelatedResources); err != nil { + return IssueClientAddOrUpdateResourcesResponse{}, err + } + return result, nil +} + +// Create - Create a new issue or updates an existing one +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-03-01-preview +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - resource - Resource create parameters. +// - options - IssueClientCreateOptions contains the optional parameters for the IssueClient.Create method. +func (client *IssueClient) Create(ctx context.Context, resourceURI string, resource IssueResource, options *IssueClientCreateOptions) (IssueClientCreateResponse, error) { + var err error + const operationName = "IssueClient.Create" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createCreateRequest(ctx, resourceURI, resource, options) + if err != nil { + return IssueClientCreateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return IssueClientCreateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return IssueClientCreateResponse{}, err + } + resp, err := client.createHandleResponse(httpResp) + return resp, err +} + +// createCreateRequest creates the Create request. +func (client *IssueClient) createCreateRequest(ctx context.Context, resourceURI string, resource IssueResource, _ *IssueClientCreateOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.AlertsManagement/issues/{issueName}" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if client.issueName == "" { + return nil, errors.New("parameter client.issueName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{issueName}", url.PathEscape(client.issueName)) + 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", "2025-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, resource); err != nil { + return nil, err + } + return req, nil +} + +// createHandleResponse handles the Create response. +func (client *IssueClient) createHandleResponse(resp *http.Response) (IssueClientCreateResponse, error) { + result := IssueClientCreateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.IssueResource); err != nil { + return IssueClientCreateResponse{}, err + } + return result, nil +} + +// Delete - Delete an issue +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-03-01-preview +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - options - IssueClientDeleteOptions contains the optional parameters for the IssueClient.Delete method. +func (client *IssueClient) Delete(ctx context.Context, resourceURI string, options *IssueClientDeleteOptions) (IssueClientDeleteResponse, error) { + var err error + const operationName = "IssueClient.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, resourceURI, options) + if err != nil { + return IssueClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return IssueClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return IssueClientDeleteResponse{}, err + } + return IssueClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *IssueClient) deleteCreateRequest(ctx context.Context, resourceURI string, _ *IssueClientDeleteOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.AlertsManagement/issues/{issueName}" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if client.issueName == "" { + return nil, errors.New("parameter client.issueName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{issueName}", url.PathEscape(client.issueName)) + 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", "2025-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// FetchInvestigationResult - Fetch investigation results +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-03-01-preview +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - body - The content of the action request +// - options - IssueClientFetchInvestigationResultOptions contains the optional parameters for the IssueClient.FetchInvestigationResult +// method. +func (client *IssueClient) FetchInvestigationResult(ctx context.Context, resourceURI string, body FetchInvestigationResultParameters, options *IssueClientFetchInvestigationResultOptions) (IssueClientFetchInvestigationResultResponse, error) { + var err error + const operationName = "IssueClient.FetchInvestigationResult" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.fetchInvestigationResultCreateRequest(ctx, resourceURI, body, options) + if err != nil { + return IssueClientFetchInvestigationResultResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return IssueClientFetchInvestigationResultResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return IssueClientFetchInvestigationResultResponse{}, err + } + resp, err := client.fetchInvestigationResultHandleResponse(httpResp) + return resp, err +} + +// fetchInvestigationResultCreateRequest creates the FetchInvestigationResult request. +func (client *IssueClient) fetchInvestigationResultCreateRequest(ctx context.Context, resourceURI string, body FetchInvestigationResultParameters, _ *IssueClientFetchInvestigationResultOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.AlertsManagement/issues/{issueName}/fetchInvestigationResult" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if client.issueName == "" { + return nil, errors.New("parameter client.issueName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{issueName}", url.PathEscape(client.issueName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// fetchInvestigationResultHandleResponse handles the FetchInvestigationResult response. +func (client *IssueClient) fetchInvestigationResultHandleResponse(resp *http.Response) (IssueClientFetchInvestigationResultResponse, error) { + result := IssueClientFetchInvestigationResultResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.InvestigationResult); err != nil { + return IssueClientFetchInvestigationResultResponse{}, err + } + return result, nil +} + +// Get - Get issue properties +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-03-01-preview +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - options - IssueClientGetOptions contains the optional parameters for the IssueClient.Get method. +func (client *IssueClient) Get(ctx context.Context, resourceURI string, options *IssueClientGetOptions) (IssueClientGetResponse, error) { + var err error + const operationName = "IssueClient.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, resourceURI, options) + if err != nil { + return IssueClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return IssueClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return IssueClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *IssueClient) getCreateRequest(ctx context.Context, resourceURI string, _ *IssueClientGetOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.AlertsManagement/issues/{issueName}" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if client.issueName == "" { + return nil, errors.New("parameter client.issueName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{issueName}", url.PathEscape(client.issueName)) + 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", "2025-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *IssueClient) getHandleResponse(resp *http.Response) (IssueClientGetResponse, error) { + result := IssueClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.IssueResource); err != nil { + return IssueClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - List all issues under the parent +// +// Generated from API version 2025-03-01-preview +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - options - IssueClientListOptions contains the optional parameters for the IssueClient.NewListPager method. +func (client *IssueClient) NewListPager(resourceURI string, options *IssueClientListOptions) *runtime.Pager[IssueClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[IssueClientListResponse]{ + More: func(page IssueClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *IssueClientListResponse) (IssueClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "IssueClient.NewListPager") + 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.listCreateRequest(ctx, resourceURI, options) + }, nil) + if err != nil { + return IssueClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *IssueClient) listCreateRequest(ctx context.Context, resourceURI string, _ *IssueClientListOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.AlertsManagement/issues" + 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", "2025-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *IssueClient) listHandleResponse(resp *http.Response) (IssueClientListResponse, error) { + result := IssueClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.IssueResourceListResult); err != nil { + return IssueClientListResponse{}, err + } + return result, nil +} + +// NewListAlertsPager - List all alerts in the issue - this method uses pagination to return all alerts +// +// Generated from API version 2025-03-01-preview +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - body - The content of the action request +// - options - IssueClientListAlertsOptions contains the optional parameters for the IssueClient.NewListAlertsPager method. +func (client *IssueClient) NewListAlertsPager(resourceURI string, body ListParameter, options *IssueClientListAlertsOptions) *runtime.Pager[IssueClientListAlertsResponse] { + return runtime.NewPager(runtime.PagingHandler[IssueClientListAlertsResponse]{ + More: func(page IssueClientListAlertsResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *IssueClientListAlertsResponse) (IssueClientListAlertsResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "IssueClient.NewListAlertsPager") + 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.listAlertsCreateRequest(ctx, resourceURI, body, options) + }, nil) + if err != nil { + return IssueClientListAlertsResponse{}, err + } + return client.listAlertsHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listAlertsCreateRequest creates the ListAlerts request. +func (client *IssueClient) listAlertsCreateRequest(ctx context.Context, resourceURI string, body ListParameter, _ *IssueClientListAlertsOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.AlertsManagement/issues/{issueName}/listAlerts" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if client.issueName == "" { + return nil, errors.New("parameter client.issueName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{issueName}", url.PathEscape(client.issueName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// listAlertsHandleResponse handles the ListAlerts response. +func (client *IssueClient) listAlertsHandleResponse(resp *http.Response) (IssueClientListAlertsResponse, error) { + result := IssueClientListAlertsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PagedRelatedAlert); err != nil { + return IssueClientListAlertsResponse{}, err + } + return result, nil +} + +// NewListResourcesPager - List all resources in the issue - this method uses pagination to return all resources +// +// Generated from API version 2025-03-01-preview +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - body - The content of the action request +// - options - IssueClientListResourcesOptions contains the optional parameters for the IssueClient.NewListResourcesPager method. +func (client *IssueClient) NewListResourcesPager(resourceURI string, body ListParameter, options *IssueClientListResourcesOptions) *runtime.Pager[IssueClientListResourcesResponse] { + return runtime.NewPager(runtime.PagingHandler[IssueClientListResourcesResponse]{ + More: func(page IssueClientListResourcesResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *IssueClientListResourcesResponse) (IssueClientListResourcesResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "IssueClient.NewListResourcesPager") + 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.listResourcesCreateRequest(ctx, resourceURI, body, options) + }, nil) + if err != nil { + return IssueClientListResourcesResponse{}, err + } + return client.listResourcesHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listResourcesCreateRequest creates the ListResources request. +func (client *IssueClient) listResourcesCreateRequest(ctx context.Context, resourceURI string, body ListParameter, _ *IssueClientListResourcesOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.AlertsManagement/issues/{issueName}/listResources" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if client.issueName == "" { + return nil, errors.New("parameter client.issueName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{issueName}", url.PathEscape(client.issueName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// listResourcesHandleResponse handles the ListResources response. +func (client *IssueClient) listResourcesHandleResponse(resp *http.Response) (IssueClientListResourcesResponse, error) { + result := IssueClientListResourcesResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PagedRelatedResource); err != nil { + return IssueClientListResourcesResponse{}, err + } + return result, nil +} + +// StartInvestigation - Start a new investigation +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-03-01-preview +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - body - The content of the action request +// - options - IssueClientStartInvestigationOptions contains the optional parameters for the IssueClient.StartInvestigation +// method. +func (client *IssueClient) StartInvestigation(ctx context.Context, resourceURI string, body StartInvestigationParameters, options *IssueClientStartInvestigationOptions) (IssueClientStartInvestigationResponse, error) { + var err error + const operationName = "IssueClient.StartInvestigation" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.startInvestigationCreateRequest(ctx, resourceURI, body, options) + if err != nil { + return IssueClientStartInvestigationResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return IssueClientStartInvestigationResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return IssueClientStartInvestigationResponse{}, err + } + resp, err := client.startInvestigationHandleResponse(httpResp) + return resp, err +} + +// startInvestigationCreateRequest creates the StartInvestigation request. +func (client *IssueClient) startInvestigationCreateRequest(ctx context.Context, resourceURI string, body StartInvestigationParameters, _ *IssueClientStartInvestigationOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.AlertsManagement/issues/{issueName}/startInvestigation" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if client.issueName == "" { + return nil, errors.New("parameter client.issueName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{issueName}", url.PathEscape(client.issueName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// startInvestigationHandleResponse handles the StartInvestigation response. +func (client *IssueClient) startInvestigationHandleResponse(resp *http.Response) (IssueClientStartInvestigationResponse, error) { + result := IssueClientStartInvestigationResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.InvestigationMetadata); err != nil { + return IssueClientStartInvestigationResponse{}, err + } + return result, nil +} + +// Update - Update an issue +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-03-01-preview +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - properties - The resource properties to be updated. +// - options - IssueClientUpdateOptions contains the optional parameters for the IssueClient.Update method. +func (client *IssueClient) Update(ctx context.Context, resourceURI string, properties IssueResourceUpdate, options *IssueClientUpdateOptions) (IssueClientUpdateResponse, error) { + var err error + const operationName = "IssueClient.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, resourceURI, properties, options) + if err != nil { + return IssueClientUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return IssueClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return IssueClientUpdateResponse{}, err + } + resp, err := client.updateHandleResponse(httpResp) + return resp, err +} + +// updateCreateRequest creates the Update request. +func (client *IssueClient) updateCreateRequest(ctx context.Context, resourceURI string, properties IssueResourceUpdate, _ *IssueClientUpdateOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.AlertsManagement/issues/{issueName}" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if client.issueName == "" { + return nil, errors.New("parameter client.issueName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{issueName}", url.PathEscape(client.issueName)) + 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", "2025-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err + } + return req, nil +} + +// updateHandleResponse handles the Update response. +func (client *IssueClient) updateHandleResponse(resp *http.Response) (IssueClientUpdateResponse, error) { + result := IssueClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.IssueResource); err != nil { + return IssueClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/models.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/models.go index 55e3b9f72d74..744d3648b873 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/models.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/models.go @@ -1,6 +1,3 @@ -//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. @@ -10,33 +7,91 @@ package armalertsmanagement import "time" -// Action to be applied. -type Action struct { - // REQUIRED; Action that should be applied. - ActionType *ActionType +// AbnormalEventAnomalyInsight - The insight for an abnormal event +type AbnormalEventAnomalyInsight struct { + // REQUIRED; The type of abnormal event + AbnormalEventType *AbnormalEventType + + // REQUIRED; The end time of the analysis (in UTC) + AnalysisEndTime *time.Time + + // REQUIRED; The start time of the analysis (in UTC) + AnalysisStartTime *time.Time + + // REQUIRED; The time when the anomaly was detected (in UTC) + AnomalyTime *time.Time + + // REQUIRED; The cloud role name for which the log was made + CloudRoleName *string + + // REQUIRED; Examples of the abnormal event + Examples []*string + + // REQUIRED; The exception pattern anomalies + ExceptionPatternAnomalies []*ExceptionPatternAnomaly + + // REQUIRED; The source of the detected anomaly, for example: target URI of a dependency, name of a failed operation, or type + // of an exception + Target *string + + // REQUIRED; The trace pattern anomalies + TracePatternAnomalies []*TracePatternAnomaly + + // REQUIRED; The transaction pattern anomalies + TransactionPatternAnomalies []*TransactionPatternAnomaly + + // The description of the abnormal event + Description *string + + // The count of failed log entries + FailedCount *int64 + + // The total count of log entries analyzed + TotalCount *int64 } -// GetAction implements the ActionClassification interface for type Action. -func (a *Action) GetAction() *Action { return a } +// AbnormalEventData - The data details for logs +type AbnormalEventData struct { + // REQUIRED; The kql filter to display + KqlFilter *string +} -// ActionGroup - A pointer to an Azure Action Group. -type ActionGroup struct { - // REQUIRED; The resource ID of the Action Group. This cannot be null or empty. - ActionGroupID *string +// AbnormalEventDetails - An abnormal event details +type AbnormalEventDetails struct { + // REQUIRED; The details category + Category *CategoryType - // Predefined list of properties and configuration items for the action group. - ActionProperties map[string]*string + // REQUIRED; The details data, which could be user generated or system generated + Data *AbnormalEventData - // the dictionary of custom properties to include with the post operation. These data are appended to the webhook payload. - WebhookProperties map[string]*string + // REQUIRED; The type of details + DetailsType *DetailsType + + // REQUIRED; Insight about the anomaly, this is system generated + Insight *AbnormalEventAnomalyInsight + + // The resource ids related to the anomaly + ResourceIDs []*string } -// ActionList - A list of Activity Log Alert rule actions. -type ActionList struct { - // The list of the Action Groups. - ActionGroups []*ActionGroup +// GetDetailsBase implements the DetailsBaseClassification interface for type AbnormalEventDetails. +func (a *AbnormalEventDetails) GetDetailsBase() *DetailsBase { + return &DetailsBase{ + Category: a.Category, + DetailsType: a.DetailsType, + ResourceIDs: a.ResourceIDs, + } +} + +// Action to be applied. +type Action struct { + // REQUIRED; Action that should be applied. + ActionType *ActionType } +// GetAction implements the ActionClassification interface for type Action. +func (a *Action) GetAction() *Action { return a } + // ActionStatus - Action status type ActionStatus struct { // Value indicating whether alert is suppressed. @@ -74,6 +129,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. @@ -189,76 +301,6 @@ type AlertProperties struct { EgressConfig any } -// AlertRuleAllOfCondition - An Activity Log Alert rule condition that is met when all its member conditions are met. -type AlertRuleAllOfCondition struct { - // REQUIRED; The list of Activity Log Alert rule conditions. - AllOf []*AlertRuleAnyOfOrLeafCondition -} - -// AlertRuleAnyOfOrLeafCondition - An Activity Log Alert rule condition that is met when all its member conditions are met. -// Each condition can be of one of the following types:Important: Each type has its unique subset of properties. -// Properties from different types CANNOT exist in one condition. -// * Leaf Condition - must contain 'field' and either 'equals' or 'containsAny'.Please note, 'anyOf' should not be set in -// a Leaf Condition. -// * AnyOf Condition - must contain only 'anyOf' (which is an array of Leaf Conditions).Please note, 'field', 'equals' and -// 'containsAny' should not be set in an AnyOf Condition. -type AlertRuleAnyOfOrLeafCondition struct { - // An Activity Log Alert rule condition that is met when at least one of its member leaf conditions are met. - AnyOf []*AlertRuleLeafCondition - - // The value of the event's field will be compared to the values in this array (case-insensitive) to determine if the condition - // is met. - ContainsAny []*string - - // The value of the event's field will be compared to this value (case-insensitive) to determine if the condition is met. - Equals *string - - // The name of the Activity Log event's field that this condition will examine. The possible values for this field are (case-insensitive): - // 'resourceId', 'category', 'caller', 'level', 'operationName', - // 'resourceGroup', 'resourceProvider', 'status', 'subStatus', 'resourceType', or anything beginning with 'properties'. - Field *string -} - -// AlertRuleLeafCondition - An Activity Log Alert rule condition that is met by comparing the field and value of an Activity -// Log event. This condition must contain 'field' and either 'equals' or 'containsAny'. -type AlertRuleLeafCondition struct { - // The value of the event's field will be compared to the values in this array (case-insensitive) to determine if the condition - // is met. - ContainsAny []*string - - // The value of the event's field will be compared to this value (case-insensitive) to determine if the condition is met. - Equals *string - - // The name of the Activity Log event's field that this condition will examine. The possible values for this field are (case-insensitive): - // 'resourceId', 'category', 'caller', 'level', 'operationName', - // 'resourceGroup', 'resourceProvider', 'status', 'subStatus', 'resourceType', or anything beginning with 'properties'. - Field *string -} - -// AlertRuleProperties - An Azure Activity Log Alert rule. -type AlertRuleProperties struct { - // REQUIRED; The actions that will activate when the condition is met. - Actions *ActionList - - // REQUIRED; The condition that will cause this alert to activate. - Condition *AlertRuleAllOfCondition - - // A description of this Activity Log Alert rule. - Description *string - - // Indicates whether this Activity Log Alert rule is enabled. If an Activity Log Alert rule is not enabled, then none of its - // actions will be activated. - Enabled *bool - - // A list of resource IDs that will be used as prefixes. The alert will only apply to Activity Log events with resource IDs - // that fall under one of these prefixes. This list must include at least one - // item. - Scopes []*string - - // The tenant GUID. Must be provided for tenant-level and management group events rules. - TenantScope *string -} - // AlertRuleRecommendationProperties - Describes the format of Alert Rule Recommendations response. type AlertRuleRecommendationProperties struct { // REQUIRED; The recommendation alert rule type. @@ -269,6 +311,9 @@ type AlertRuleRecommendationProperties struct { // 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. @@ -367,6 +412,87 @@ type AlertsSummaryGroupItem struct { Values []*AlertsSummaryGroupItem } +// AnomalyRange - The range for anomaly scanning +type AnomalyRange struct { + // REQUIRED; The end time of the range (in UTC) + End *time.Time + + // REQUIRED; The start time of the range (in UTC) + Start *time.Time +} + +// AzureMetricAnomalyInsight - The insight for a metric anomaly +type AzureMetricAnomalyInsight struct { + // REQUIRED; The direction of the anomaly + AnomalyDirection *AnomalyDirection + + // REQUIRED; The range of that was scanned for anomalies + AnomalyScanRange *AnomalyRange + + // REQUIRED; The time of the anomaly (in UTC) + AnomalyTime *time.Time + + // REQUIRED; The baseline range for the metric + Thresholds *BaselineRange +} + +// AzureMetricData - The data details for azure metrics +type AzureMetricData struct { + // REQUIRED; The dimensions of the metric + Dimensions map[string][]*string + + // REQUIRED; The aggregation type of the metric + MetricAggregation *AggregationType + + // REQUIRED; The interval at which the metric is collected + MetricInterval *string + + // REQUIRED; The name of the metric + MetricName *string + + // REQUIRED; The namespace of the metric + MetricNamespace *string + + // REQUIRED; The range for anomaly scanning + ScanRange *AnomalyRange +} + +// AzureMetricDetails - An azure metric details +type AzureMetricDetails struct { + // REQUIRED; The details category + Category *CategoryType + + // REQUIRED; The details data, which could be user generated or system generated + Data *AzureMetricData + + // REQUIRED; The type of details + DetailsType *DetailsType + + // REQUIRED; Insight about the anomaly, which is system generated + Insight *AzureMetricAnomalyInsight + + // The resource ids related to the anomaly + ResourceIDs []*string +} + +// GetDetailsBase implements the DetailsBaseClassification interface for type AzureMetricDetails. +func (a *AzureMetricDetails) GetDetailsBase() *DetailsBase { + return &DetailsBase{ + Category: a.Category, + DetailsType: a.DetailsType, + ResourceIDs: a.ResourceIDs, + } +} + +// BaselineRange - The range for the baseline for an anomaly +type BaselineRange struct { + // REQUIRED; The highest value of the range + High *float64 + + // REQUIRED; The lowest value of the range + Low *float64 +} + // Comments - Change alert state reason type Comments struct { Comments *string @@ -384,6 +510,19 @@ type Condition struct { Values []*string } +// CorrelationDetails - Correlation details +type CorrelationDetails struct { + // READ-ONLY; The alert processing rule that was used to correlate this alert. This is an optional field, it will be presented + // only for a parent alert. + AlertProcessingRule *string + + // READ-ONLY; The alert's correlation date time in ISO-8601 format. + CorrelationDateTime *time.Time + + // READ-ONLY; Unique Id (GUID) of the alert that this alert was correlated to. + ParentAlertID *string +} + // DailyRecurrence - Daily recurrence object. type DailyRecurrence struct { // REQUIRED; Specifies when the recurrence should be applied. @@ -405,11 +544,71 @@ func (d *DailyRecurrence) GetRecurrence() *Recurrence { } } +// DetailsBase - The details base type +type DetailsBase struct { + // REQUIRED; The details category + Category *CategoryType + + // REQUIRED; The type of details + DetailsType *DetailsType + + // The resource ids related to the anomaly + ResourceIDs []*string +} + +// GetDetailsBase implements the DetailsBaseClassification interface for type DetailsBase. +func (d *DetailsBase) GetDetailsBase() *DetailsBase { return d } + +// DiagnosticsInsight - The insight for diagnostics +type DiagnosticsInsight struct { + // REQUIRED; The diagnostics HTML content + Content *string + + // REQUIRED; The diagnostics solution Id + SolutionID *string +} + +// DiagnosticsSolutionDetails - An diagnostics details +type DiagnosticsSolutionDetails struct { + // REQUIRED; The details category + Category *CategoryType + + // REQUIRED; The type of details + DetailsType *DetailsType + + // REQUIRED; Insight about the anomaly, this is system generated + Insight *DiagnosticsInsight + + // The resource ids related to the anomaly + ResourceIDs []*string +} + +// GetDetailsBase implements the DetailsBaseClassification interface for type DiagnosticsSolutionDetails. +func (d *DiagnosticsSolutionDetails) GetDetailsBase() *DetailsBase { + return &DetailsBase{ + Category: d.Category, + DetailsType: d.DetailsType, + ResourceIDs: d.ResourceIDs, + } +} + +// DimensionNameAndValue - Dimension name and value +type DimensionNameAndValue struct { + // REQUIRED; Name of the dimension + Name *string + + // REQUIRED; Value of the dimension + Value *string +} + // Essentials - This object contains consistent fields across different monitor services. type Essentials struct { // Action status ActionStatus *ActionStatus + // Correlation details + CorrelationDetails *CorrelationDetails + // Alert description. Description *string @@ -432,6 +631,12 @@ type Essentials struct { // READ-ONLY; Alert object state, which can be modified by the user. AlertState *AlertState + // READ-ONLY; Will be presented with the value true only if there are enrichments. + HasEnrichments *bool + + // READ-ONLY; True if the alert is stateful, and false if it isn't. + IsStatefulAlert *bool + // READ-ONLY; Last modification time(ISO-8601 format) of alert instance. LastModifiedDateTime *time.Time @@ -470,6 +675,461 @@ type Essentials struct { StartDateTime *time.Time } +// EvaluatedPeriod - Details of the evaluated period. +type EvaluatedPeriod struct { + // The high threshold value for the evaluation period. + HighThreshold *float64 + + // The low threshold value for the evaluation period. + LowThreshold *float64 + + // The metric value for the evaluation period. + MetricValue *float64 + + // Indicates whether the threshold was met during the evaluation period. + ThresholdMet *bool + + // The timestamp of the evaluated period. + Timestamp *time.Time +} + +// Evaluation - An evaluation of the alert rule. +type Evaluation struct { + // The state of the alert after the evaluation. + AlertState *AlertState + + // An array of evaluated periods. + EvaluatedPeriods []*EvaluatedPeriod + + // The time when the evaluation was performed. + EvaluationTime *time.Time + + // Indicates whether the threshold was met for this evaluation. + ThresholdMet *bool +} + +// ExceptionPatternAnomaly - The exception pattern anomaly +type ExceptionPatternAnomaly struct { + // REQUIRED; The count of the exception occurrences + Count *int32 + + // REQUIRED; The generated message for the exception + GeneratedMessage *string + + // REQUIRED; The exception's item ID, from the Application Insights telemetry data model + ItemID *string + + // REQUIRED; The problem ID of the exception, from the Application Insights telemetry data model + ProblemID *string +} + +// FetchInvestigationResultParameters - Parameters provided to get the investigation result +type FetchInvestigationResultParameters struct { + // REQUIRED; The unique identifier of the investigation + InvestigationID *string +} + +// InvestigationDetails - An investigation details +type InvestigationDetails struct { + // REQUIRED; The details category + Category *CategoryType + + // REQUIRED; The parameters used for this investigation execution + Data *StartInvestigationParameters + + // REQUIRED; The type of details + DetailsType *DetailsType + + // The resource ids related to the anomaly + ResourceIDs []*string +} + +// GetDetailsBase implements the DetailsBaseClassification interface for type InvestigationDetails. +func (i *InvestigationDetails) GetDetailsBase() *DetailsBase { + return &DetailsBase{ + Category: i.Category, + DetailsType: i.DetailsType, + ResourceIDs: i.ResourceIDs, + } +} + +// InvestigationEntity - Details about the investigation entity +type InvestigationEntity struct { + // REQUIRED; The creation time of the entity (in UTC) + CreatedAt *time.Time + + // REQUIRED; The type of the entity + EntityType *InvestigationEntityType + + // REQUIRED; The execution details of the entity + Execution *InvestigationExecution + + // REQUIRED; The health state of the entity + HealthState *HealthState + + // REQUIRED; The identifier of the entity + ID *string + + // REQUIRED; The last update time of the entity (in UTC) + LastModifiedAt *time.Time + + // REQUIRED; The origin of the entity + Origin *Origin + + // The children of this investigation entity + Children []*InvestigationEntity + + // The details of the entity + Details DetailsBaseClassification + + // The relevance of the entity + Relevance *Relevance + + // The summary of the entity + Summary *Summary +} + +// InvestigationExecution - Details about the execution of the investigation +type InvestigationExecution struct { + // REQUIRED; The time at which the investigation execution completed (in UTC) + CompletedAt *time.Time + + // READ-ONLY; The state of the investigation execution + RunState *InvestigationExecutionRunState +} + +// InvestigationMetadata - Properties of the current investigation +type InvestigationMetadata struct { + // REQUIRED; The creation time of the investigation (in UTC) + CreatedAt *time.Time + + // REQUIRED; The execution details of the investigation + Execution *InvestigationExecution + + // REQUIRED; The unique identifier of the investigation + ID *string + + // REQUIRED; The parameters that were used to start the investigation + RunParameters *RunParameters +} + +// InvestigationResult - Details about the investigation result +type InvestigationResult struct { + // REQUIRED; The children of this investigation, findings and evidences + Children []*InvestigationEntity + + // REQUIRED; The creation time of the investigation (in UTC) + CreatedAt *time.Time + + // REQUIRED; The type of the investigation + EntityType *InvestigationEntityType + + // REQUIRED; The execution details of the investigation + Execution *InvestigationExecution + + // REQUIRED; The identifier of the investigation + ID *string + + // REQUIRED; The last update time of the investigation (in UTC) + LastModifiedAt *time.Time + + // REQUIRED; The origin of the investigation + Origin *Origin + + // REQUIRED; The parameters used to run the investigation + RunParameters *RunParameters +} + +// InvestigationScope - A single scope of the investigation +type InvestigationScope struct { + // REQUIRED; The ID of the scope of the investigation - either an Azure alert ID or an Azure resource ID + ID *string + + // REQUIRED; The origin of the scope + Origin *Origin + + // The relevance of the scope + Relevance *Relevance +} + +// IssueProperties - The issue properties +type IssueProperties struct { + // REQUIRED; The issue impact time (in UTC) + ImpactTime *time.Time + + // REQUIRED; The issue severity + Severity *string + + // REQUIRED; The issue status + Status *Status + + // REQUIRED; The issue title + Title *string + + // READ-ONLY; The list of investigations in the issue + Investigations []*InvestigationMetadata + + // READ-ONLY; The number of investigations in the issue + InvestigationsCount *int32 + + // READ-ONLY; The provisioning state of the resource. + ProvisioningState *ResourceProvisioningState +} + +// IssuePropertiesUpdate - The issue properties +type IssuePropertiesUpdate struct { + // The issue impact time (in UTC) + ImpactTime *time.Time + + // The issue severity + Severity *string + + // The issue status + Status *Status + + // The issue title + Title *string +} + +// IssueResource - The Issue resource +type IssueResource struct { + // The resource-specific properties for this resource. + Properties *IssueProperties + + // 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 +} + +// IssueResourceListResult - The response of a IssueResource list operation. +type IssueResourceListResult struct { + // REQUIRED; The IssueResource items on this page + Value []*IssueResource + + // The link to the next page of items + NextLink *string +} + +// IssueResourceUpdate - The Issue resource +type IssueResourceUpdate struct { + // The resource-specific properties for this resource. + Properties *IssuePropertiesUpdate + + // 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 +} + +// ListParameter - Parameters for listing related entities +type ListParameter struct { + // The filter to apply on the operation. For example, to filter by relevance, use "$filter=relevance eq 'Relevant'" + Filter *string +} + +// LogAlertRuleCondition - A condition of the scheduled query rule. +type LogAlertRuleCondition struct { + // The extent of deviation required to trigger an alert. Allowed values are 'Low', 'Medium' and 'High'. This will affect how + // tight the threshold is to the metric series pattern. Relevant and required + // only for dynamic threshold rules of the kind LogAlert. + AlertSensitivity *string + + // Specifies the type of threshold criteria + CriterionType *CriterionType + + // List of Dimensions conditions + Dimensions []*LogAlertRuleDimension + + // The minimum number of violations required within the selected lookback time window required to raise an alert. Relevant + // only for rules of the kind LogAlert. + FailingPeriods *LogAlertRuleConditionFailingPeriods + + // Use this option to set the date from which to start learning the metric historical data and calculate the dynamic thresholds + // (in ISO8601 format). Relevant only for dynamic threshold rules of the kind + // LogAlert. + IgnoreDataBefore *time.Time + + // The column containing the metric measure number. Relevant only for rules of the kind LogAlert. + MetricMeasureColumn *string + + // The name of the metric to be sent. Relevant and required only for rules of the kind LogToMetric. + MetricName *string + + // The criteria operator. Relevant and required only for rules of the kind LogAlert. + Operator *ConditionOperator + + // Log query alert + Query *string + + // The column containing the resource id. The content of the column must be a uri formatted as resource id. Relevant only + // for rules of the kind LogAlert. + ResourceIDColumn *string + + // the criteria threshold value that activates the alert. Relevant and required only for static threshold rules of the kind + // LogAlert. + Threshold *float64 + + // Aggregation type. Relevant and required only for rules of the kind LogAlert. + TimeAggregation *TimeAggregation +} + +// LogAlertRuleConditionFailingPeriods - The minimum number of violations required within the selected lookback time window +// required to raise an alert. Relevant only for rules of the kind LogAlert. +type LogAlertRuleConditionFailingPeriods struct { + // The number of violations to trigger an alert. Should be smaller or equal to numberOfEvaluationPeriods. Default value is + // 1 + MinFailingPeriodsToAlert *int64 + + // The number of aggregated lookback points. The lookback time window is calculated based on the aggregation granularity (windowSize) + // and the selected number of aggregated points. Default value is 1 + NumberOfEvaluationPeriods *int64 +} + +// LogAlertRuleCriteria - The rule criteria that defines the conditions of the scheduled query rule. +type LogAlertRuleCriteria struct { + // A list of conditions to evaluate against the specified scopes + AllOf []*LogAlertRuleCondition +} + +// LogAlertRuleDimension - Dimension splitting and filtering definition +type LogAlertRuleDimension struct { + // REQUIRED; Name of the dimension + Name *string + + // REQUIRED; Operator for dimension values + Operator *DimensionOperator + + // REQUIRED; List of dimension values + Values []*string +} + +// LogAlertRuleProperties - scheduled query rule Definition +type LogAlertRuleProperties struct { + // The flag that indicates whether the alert should be automatically resolved or not. The default is true. Relevant only for + // rules of the kind LogAlert. + AutoMitigate *bool + + // The flag which indicates whether this scheduled query rule should be stored in the customer's storage. The default is false. + // Relevant only for rules of the kind LogAlert. + CheckWorkspaceAlertsStorageConfigured *bool + + // The rule criteria that defines the conditions of the scheduled query rule. + Criteria *LogAlertRuleCriteria + + // The description of the scheduled query rule. + Description *string + + // The display name of the alert rule + DisplayName *string + + // The flag which indicates whether this scheduled query rule is enabled. Value should be true or false + Enabled *bool + + // How often the scheduled query rule is evaluated represented in ISO 8601 duration format. Relevant and required only for + // rules of the kind LogAlert. + EvaluationFrequency *string + + // Mute actions for the chosen period of time (in ISO 8601 duration format) after the alert is fired. Relevant only for rules + // of the kind LogAlert. + MuteActionsDuration *string + + // If specified then overrides the query time range (default is WindowSize*NumberOfEvaluationPeriods). Relevant only for rules + // of the kind LogAlert. + OverrideQueryTimeRange *string + + // Defines the configuration for resolving fired alerts. Relevant only for rules of the kind LogAlert. + ResolveConfiguration *LogAlertRuleResolveConfiguration + + // The list of resource id's that this scheduled query rule is scoped to. + Scopes []*string + + // Severity of the alert. Should be an integer between [0-4]. Value of 0 is severest. Relevant and required only for rules + // of the kind LogAlert. + Severity *AlertSeverity + + // The flag which indicates whether the provided query should be validated or not. The default is false. Relevant only for + // rules of the kind LogAlert. + SkipQueryValidation *bool + + // List of resource type of the target resource(s) on which the alert is created/updated. For example if the scope is a resource + // group and targetResourceTypes is Microsoft.Compute/virtualMachines, then a + // different alert will be fired for each virtual machine in the resource group which meet the alert criteria. Relevant only + // for rules of the kind LogAlert + TargetResourceTypes []*string + + // The period of time (in ISO 8601 duration format) on which the Alert query will be executed (bin size). Relevant and required + // only for rules of the kind LogAlert. + WindowSize *string + + // READ-ONLY; The api-version used when creating this alert rule + CreatedWithAPIVersion *string + + // READ-ONLY; True if alert rule is legacy Log Analytic rule + IsLegacyLogAnalyticsRule *bool + + // READ-ONLY; The flag which indicates whether this scheduled query rule has been configured to be stored in the customer's + // storage. The default is false. + IsWorkspaceAlertsStorageConfigured *bool +} + +// LogAlertRuleResolveConfiguration - TBD. Relevant only for rules of the kind LogAlert. +type LogAlertRuleResolveConfiguration struct { + // The flag that indicates whether or not to auto resolve a fired alert. + AutoResolved *bool + + // The duration a rule must evaluate as healthy before the fired alert is automatically resolved represented in ISO 8601 duration + // format. + TimeToResolve *string +} + +// LogAlertRuleResource - The scheduled query rule resource. +type LogAlertRuleResource struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // REQUIRED; The rule properties of the resource. + Properties *LogAlertRuleProperties + + // Indicates the type of scheduled query rule. The default is LogAlert. + Kind *Kind + + // Resource tags. + Tags map[string]*string + + // READ-ONLY; The etag field is not required. If it is provided in the response body, it must also be provided as a header + // per the normal etag convention. Entity tags are used for comparing two or more entities + // from the same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section 14.24), If-None-Match + // (section 14.26), and If-Range (section 14.27) header fields. + Etag *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; SystemData of ScheduledQueryRule. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + // MonitorServiceDetails - Details of a monitor service type MonitorServiceDetails struct { // Monitor service display name @@ -555,6 +1215,34 @@ type OperationsList struct { NextLink *string } +// Origin - Details about the origin of the entity - the source that added it to the issue +type Origin struct { + // REQUIRED; The ID of the origin - for example, in case of 'Manual', the object ID of the identity, and in case of 'Automatic', + // the name of the automatic system + AddedBy *string + + // REQUIRED; The source of the origin - Manual or Automatic + AddedByType *AddedByType +} + +// PagedRelatedAlert - Paged collection of RelatedAlert items +type PagedRelatedAlert struct { + // REQUIRED; The RelatedAlert items on this page + Value []*RelatedAlert + + // The link to the next page of items + NextLink *string +} + +// PagedRelatedResource - Paged collection of RelatedResource items +type PagedRelatedResource struct { + // REQUIRED; The RelatedResource items on this page + Value []*RelatedResource + + // The link to the next page of items + NextLink *string +} + // PatchObject - Data contract for patch. type PatchObject struct { // Properties supported by patch operation. @@ -570,36 +1258,232 @@ type PatchProperties struct { Enabled *bool } +type PreviewAlertRuleRequest struct { + // REQUIRED; The location of the rule resource. + Location *string + + // REQUIRED + Properties *PreviewAlertRuleRequestProperties +} + +type PreviewAlertRuleRequestProperties struct { + // REQUIRED; The properties of the alert rule to preview. + AlertRuleProperties *LogAlertRuleResource + + // REQUIRED; The type of the alert rule to be previewed. + AlertRuleType *string + + // REQUIRED; Specifies the lookback of the preview. + LookbackPeriod *string +} + +type PreviewAlertRuleResponse struct { + // An array of rule preview results. + RulePreviewResults []*RulePreviewResult +} + +// 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 expression to run for the rule. + // 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 - // The array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved. Only - // relevant for alerts. + // Actions that are performed when the alert rule becomes active, and when an alert condition is resolved. Actions []*PrometheusRuleGroupAction - // the name of the alert rule. + // Alert rule name. Alert *string - // annotations for rule group. Only relevant for alerts. + // 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 - // the flag that indicates whether the Prometheus rule is enabled. + // Enable/disable rule. Enabled *bool - // the amount of time alert must be active before firing. Only relevant for alerts. + // The amount of time alert must be active before firing. For *string - // labels for rule group. Only relevant for alerts. + // Labels to add or overwrite before storing the result. Labels map[string]*string - // the name of the recording rule. + // Recorded metrics name. Record *string - // defines the configuration for resolving fired alerts. Only relevant for alerts. + // Defines the configuration for resolving fired alerts. Only relevant for alerts. ResolveConfiguration *PrometheusRuleResolveConfiguration - // the severity of the alerts fired by the rule. Only relevant for alerts. + // The severity of the alerts fired by the rule. Must be between 0 and 4. Severity *int32 } @@ -612,24 +1496,25 @@ type PrometheusRuleGroupAction struct { ActionProperties map[string]*string } -// PrometheusRuleGroupProperties - An alert rule. +// PrometheusRuleGroupProperties - An Azure Prometheus rule group. type PrometheusRuleGroupProperties struct { - // REQUIRED; defines the rules in the Prometheus rule group. + // REQUIRED; Defines the rules in the Prometheus rule group. Rules []*PrometheusRule - // REQUIRED; the list of resource id's that this rule group is scoped to. + // 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 - // the cluster name of the rule group evaluation. + // Apply rule to data from a specific cluster. ClusterName *string - // the description of the Prometheus rule group that will be included in the alert email. + // Rule group description. Description *string - // the flag that indicates whether the Prometheus rule group is enabled. + // 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 + // 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 } @@ -664,26 +1549,25 @@ type PrometheusRuleGroupResourceCollection struct { Value []*PrometheusRuleGroupResource } -// PrometheusRuleGroupResourcePatch - The Prometheus rule group resource for patch operations. -type PrometheusRuleGroupResourcePatch struct { - Properties *PrometheusRuleGroupResourcePatchProperties +// PrometheusRuleGroupResourcePatchParameters - The Prometheus rule group resource for patch operations. +type PrometheusRuleGroupResourcePatchParameters struct { + Properties *PrometheusRuleGroupResourcePatchParametersProperties // Resource tags Tags map[string]*string } -type PrometheusRuleGroupResourcePatchProperties struct { +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 { - // the flag that indicates whether or not to auto resolve a fired alert. + // Enable alert auto-resolution. AutoResolved *bool - // the duration a rule must evaluate as healthy before the fired alert is automatically resolved represented in ISO 8601 duration - // format. Should be between 1 and 15 minutes + // Alert auto-resolution timeout. TimeToResolve *string } @@ -702,6 +1586,96 @@ type Recurrence struct { // GetRecurrence implements the RecurrenceClassification interface for type Recurrence. func (r *Recurrence) GetRecurrence() *Recurrence { return r } +// RelatedAlert - Properties of an alert which is related to the issue +type RelatedAlert struct { + // REQUIRED; The alert ID + ID *string + + // REQUIRED; The alerts's relevance status + Relevance *Relevance + + // READ-ONLY; The time this relation was added to the issue (in UTC) + AddedAt *time.Time + + // READ-ONLY; The last update time of this relation (in UTC) + LastModifiedAt *time.Time + + // READ-ONLY; The source that related the alert to the issue + Origin *Origin +} + +// RelatedAlertAnomalyInsight - The insight for a related alert +type RelatedAlertAnomalyInsight struct { + // REQUIRED; The time when the anomaly was detected (in UTC) + AnomalyTime *time.Time + + // REQUIRED; The time when the alert was fired (in UTC) + FiredTime *time.Time +} + +// RelatedAlertData - The data details for alerts +type RelatedAlertData struct { + // REQUIRED; The fired alert id + FiredAlertID *string +} + +// RelatedAlertDetails - A related alert details +type RelatedAlertDetails struct { + // REQUIRED; The details category + Category *CategoryType + + // REQUIRED; The details data, which could be user generated or system generated + Data *RelatedAlertData + + // REQUIRED; The type of details + DetailsType *DetailsType + + // REQUIRED; Insight about the anomaly, this is system generated + Insight *RelatedAlertAnomalyInsight + + // The resource ids related to the anomaly + ResourceIDs []*string +} + +// GetDetailsBase implements the DetailsBaseClassification interface for type RelatedAlertDetails. +func (r *RelatedAlertDetails) GetDetailsBase() *DetailsBase { + return &DetailsBase{ + Category: r.Category, + DetailsType: r.DetailsType, + ResourceIDs: r.ResourceIDs, + } +} + +// RelatedAlerts - A list of related alerts +type RelatedAlerts struct { + // REQUIRED; A list of related alerts + Value []*RelatedAlert +} + +// RelatedResource - Properties of a resource which is related to the issue +type RelatedResource struct { + // REQUIRED; The resource ID + ID *string + + // REQUIRED; The resource's relevance status + Relevance *Relevance + + // READ-ONLY; The time this relation was added to the issue (in UTC) + AddedAt *time.Time + + // READ-ONLY; The last update time of this relation (in UTC) + LastModifiedAt *time.Time + + // READ-ONLY; The source that related the resource to the issue + Origin *Origin +} + +// RelatedResources - A list of related resources +type RelatedResources struct { + // REQUIRED; A list of related resources + Value []*RelatedResource +} + // RemoveAllActionGroups - Indicates if all action groups should be removed. type RemoveAllActionGroups struct { // REQUIRED; Action that should be applied. @@ -715,6 +1689,45 @@ func (r *RemoveAllActionGroups) GetAction() *Action { } } +// ResourceHealthDetails - A resource health details +type ResourceHealthDetails struct { + // REQUIRED; The details category + Category *CategoryType + + // REQUIRED; The type of details + DetailsType *DetailsType + + // REQUIRED; Insight about the anomaly, this is system generated + Insight *ResourceHealthInsight + + // The resource ids related to the anomaly + ResourceIDs []*string +} + +// GetDetailsBase implements the DetailsBaseClassification interface for type ResourceHealthDetails. +func (r *ResourceHealthDetails) GetDetailsBase() *DetailsBase { + return &DetailsBase{ + Category: r.Category, + DetailsType: r.DetailsType, + ResourceIDs: r.ResourceIDs, + } +} + +// ResourceHealthInsight - The insight for resource health +type ResourceHealthInsight struct { + // REQUIRED; The availability state of the resource + AvailabilityState *AvailabilityState + + // REQUIRED; The time when the resource health event occurred (in UTC) + OccurredTime *time.Time + + // REQUIRED; The summary of the resource health event + Summary *string + + // REQUIRED; The title of the resource health event + Title *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 @@ -733,6 +1746,27 @@ type RuleArmTemplate struct { Variables any } +// RulePreviewResult - A rule preview result containing a dimension combination and an array of evaluations. +type RulePreviewResult struct { + // The list of dimensions for the evaluation. + DimensionCombinations []*DimensionNameAndValue + + // An array of evaluations. + Evaluations []*Evaluation +} + +// RunParameters - The parameters used to run the investigation +type RunParameters struct { + // REQUIRED; The alerts used to run the investigation + Alerts []*InvestigationScope + + // REQUIRED; The impact time to investigate (in UTC) + ImpactTime *time.Time + + // REQUIRED; The resources used to run the investigation + Resources []*InvestigationScope +} + // 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. @@ -877,6 +1911,31 @@ type SmartGroupsList struct { Value []*SmartGroup } +// StartInvestigationParameters - Parameters provided to start an investigation operation +type StartInvestigationParameters struct { + // REQUIRED; The scope of the investigation (resources and alerts) - by default, the resources and alerts related to the issue + // are used + InvestigationScopes []*InvestigationScope + + // The impact time to use for this investigation - by default, the impact time from the issue is used (in UTC) + ImpactTime *time.Time +} + +// Summary - The text summary of the investigation entity +type Summary struct { + // REQUIRED; Possible explanation of the entity + PossibleExplanation *string + + // REQUIRED; The title of the entity + Title *string + + // REQUIRED; Suggestions for next steps + WhatCanBeDoneNext *string + + // REQUIRED; Description of what happened + WhatHappened *string +} + // SystemData - Metadata pertaining to creation and last modification of the resource. type SystemData struct { // The timestamp of resource creation (UTC). @@ -898,51 +1957,58 @@ type SystemData struct { LastModifiedByType *CreatedByType } -// TenantActivityLogAlertResource - A Tenant Activity Log Alert rule resource. -type TenantActivityLogAlertResource struct { - // REQUIRED; The Activity Log Alert rule properties of the resource. - Properties *AlertRuleProperties +// TracePatternAnomaly - The trace pattern anomaly +type TracePatternAnomaly struct { + // REQUIRED; The count of the trace occurrences + Count *int32 - // The location of the resource. Since Azure Activity Log Alerts is a global service, the location of the rules should always - // be 'global'. - Location *string + // REQUIRED; A generated message that describes the anomalous trace pattern + GeneratedMessage *string - // The tags of the resource. - Tags map[string]*string + // REQUIRED; The anomalous trace pattern that was detected in the Application Insights traces table + Pattern *string - // READ-ONLY; The resource Id. - ID *string + // REQUIRED; The sample event of the trace pattern + SampleEvent *string +} - // READ-ONLY; The name of the resource. - Name *string +// TransactionEdge - The edge of a transaction pattern +type TransactionEdge struct { + // REQUIRED; The textual identifier of the end node of the edge + End *string - // READ-ONLY; The type of the resource. - Type *string + // REQUIRED; The edge's metadata + Metadata map[string]*string + + // REQUIRED; The textual identifier of the start node of the edge + Start *string } -// TenantAlertRuleList - A list of Tenant Activity Log Alert rules. -type TenantAlertRuleList struct { - // Provides the link to retrieve the next set of elements. - NextLink *string +// TransactionNode - The node of a transaction pattern +type TransactionNode struct { + // REQUIRED; The textual identifier of the transaction participant's node + ID *string - // The list of Tenant Activity Log Alert rules. - Value []*TenantActivityLogAlertResource + // REQUIRED; The node's metadata + Metadata map[string]*string } -// TenantAlertRulePatchObject - An Activity Log Alert rule object for the body of patch operations. -type TenantAlertRulePatchObject struct { - // The activity log alert settings for an update operation. - Properties *TenantAlertRulePatchProperties +// TransactionPatternAnomaly - The transaction pattern anomaly +type TransactionPatternAnomaly struct { + // REQUIRED; The edges of the transaction pattern + Edges []*TransactionEdge - // The resource tags - Tags map[string]*string -} + // REQUIRED; A generated message that describes the anomalous transaction pattern + GeneratedMessage *string -// TenantAlertRulePatchProperties - An Activity Log Alert rule properties for patch operations. -type TenantAlertRulePatchProperties struct { - // Indicates whether this Activity Log Alert rule is enabled. If an Activity Log Alert rule is not enabled, then none of its - // actions will be activated. - Enabled *bool + // REQUIRED; The name of the transaction pattern + Name *string + + // REQUIRED; The nodes of the transaction pattern + Nodes []*TransactionNode + + // REQUIRED; The textual identifier of the target of the anomalous transaction + TargetNode *string } // WeeklyRecurrence - Weekly recurrence object. diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/models_serde.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/models_serde.go index 5d77ba38aab5..ec07ee767010 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/models_serde.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/models_serde.go @@ -1,6 +1,3 @@ -//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. @@ -15,15 +12,27 @@ import ( "reflect" ) -// MarshalJSON implements the json.Marshaller interface for type Action. -func (a Action) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type AbnormalEventAnomalyInsight. +func (a AbnormalEventAnomalyInsight) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - objectMap["actionType"] = a.ActionType + populate(objectMap, "abnormalEventType", a.AbnormalEventType) + populateDateTimeRFC3339(objectMap, "analysisEndTime", a.AnalysisEndTime) + populateDateTimeRFC3339(objectMap, "analysisStartTime", a.AnalysisStartTime) + populateDateTimeRFC3339(objectMap, "anomalyTime", a.AnomalyTime) + populate(objectMap, "cloudRoleName", a.CloudRoleName) + populate(objectMap, "description", a.Description) + populate(objectMap, "examples", a.Examples) + populate(objectMap, "exceptionPatternAnomalies", a.ExceptionPatternAnomalies) + populate(objectMap, "failedCount", a.FailedCount) + populate(objectMap, "target", a.Target) + populate(objectMap, "totalCount", a.TotalCount) + populate(objectMap, "tracePatternAnomalies", a.TracePatternAnomalies) + populate(objectMap, "transactionPatternAnomalies", a.TransactionPatternAnomalies) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type Action. -func (a *Action) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type AbnormalEventAnomalyInsight. +func (a *AbnormalEventAnomalyInsight) 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) @@ -31,8 +40,44 @@ func (a *Action) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "actionType": - err = unpopulate(val, "ActionType", &a.ActionType) + case "abnormalEventType": + err = unpopulate(val, "AbnormalEventType", &a.AbnormalEventType) + delete(rawMsg, key) + case "analysisEndTime": + err = unpopulateDateTimeRFC3339(val, "AnalysisEndTime", &a.AnalysisEndTime) + delete(rawMsg, key) + case "analysisStartTime": + err = unpopulateDateTimeRFC3339(val, "AnalysisStartTime", &a.AnalysisStartTime) + delete(rawMsg, key) + case "anomalyTime": + err = unpopulateDateTimeRFC3339(val, "AnomalyTime", &a.AnomalyTime) + delete(rawMsg, key) + case "cloudRoleName": + err = unpopulate(val, "CloudRoleName", &a.CloudRoleName) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &a.Description) + delete(rawMsg, key) + case "examples": + err = unpopulate(val, "Examples", &a.Examples) + delete(rawMsg, key) + case "exceptionPatternAnomalies": + err = unpopulate(val, "ExceptionPatternAnomalies", &a.ExceptionPatternAnomalies) + delete(rawMsg, key) + case "failedCount": + err = unpopulate(val, "FailedCount", &a.FailedCount) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &a.Target) + delete(rawMsg, key) + case "totalCount": + err = unpopulate(val, "TotalCount", &a.TotalCount) + delete(rawMsg, key) + case "tracePatternAnomalies": + err = unpopulate(val, "TracePatternAnomalies", &a.TracePatternAnomalies) + delete(rawMsg, key) + case "transactionPatternAnomalies": + err = unpopulate(val, "TransactionPatternAnomalies", &a.TransactionPatternAnomalies) delete(rawMsg, key) } if err != nil { @@ -42,17 +87,15 @@ func (a *Action) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type ActionGroup. -func (a ActionGroup) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type AbnormalEventData. +func (a AbnormalEventData) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "actionGroupId", a.ActionGroupID) - populate(objectMap, "actionProperties", a.ActionProperties) - populate(objectMap, "webhookProperties", a.WebhookProperties) + populate(objectMap, "kqlFilter", a.KqlFilter) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ActionGroup. -func (a *ActionGroup) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type AbnormalEventData. +func (a *AbnormalEventData) 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) @@ -60,14 +103,51 @@ func (a *ActionGroup) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "actionGroupId": - err = unpopulate(val, "ActionGroupID", &a.ActionGroupID) + case "kqlFilter": + err = unpopulate(val, "KqlFilter", &a.KqlFilter) delete(rawMsg, key) - case "actionProperties": - err = unpopulate(val, "ActionProperties", &a.ActionProperties) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AbnormalEventDetails. +func (a AbnormalEventDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "category", a.Category) + populate(objectMap, "data", a.Data) + objectMap["detailsType"] = DetailsTypeAbnormalEvent + populate(objectMap, "insight", a.Insight) + populate(objectMap, "resourceIds", a.ResourceIDs) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AbnormalEventDetails. +func (a *AbnormalEventDetails) 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 "category": + err = unpopulate(val, "Category", &a.Category) + delete(rawMsg, key) + case "data": + err = unpopulate(val, "Data", &a.Data) + delete(rawMsg, key) + case "detailsType": + err = unpopulate(val, "DetailsType", &a.DetailsType) + delete(rawMsg, key) + case "insight": + err = unpopulate(val, "Insight", &a.Insight) delete(rawMsg, key) - case "webhookProperties": - err = unpopulate(val, "WebhookProperties", &a.WebhookProperties) + case "resourceIds": + err = unpopulate(val, "ResourceIDs", &a.ResourceIDs) delete(rawMsg, key) } if err != nil { @@ -77,15 +157,15 @@ func (a *ActionGroup) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type ActionList. -func (a ActionList) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type Action. +func (a Action) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "actionGroups", a.ActionGroups) + objectMap["actionType"] = a.ActionType return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ActionList. -func (a *ActionList) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type Action. +func (a *Action) 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) @@ -93,8 +173,8 @@ func (a *ActionList) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "actionGroups": - err = unpopulate(val, "ActionGroups", &a.ActionGroups) + case "actionType": + err = unpopulate(val, "ActionType", &a.ActionType) delete(rawMsg, key) } if err != nil { @@ -201,6 +281,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) @@ -486,15 +714,18 @@ func (a *AlertProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type AlertRuleAllOfCondition. -func (a AlertRuleAllOfCondition) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type AlertRuleRecommendationProperties. +func (a AlertRuleRecommendationProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "allOf", a.AllOf) + 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 AlertRuleAllOfCondition. -func (a *AlertRuleAllOfCondition) UnmarshalJSON(data []byte) error { +// 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) @@ -502,8 +733,17 @@ func (a *AlertRuleAllOfCondition) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "allOf": - err = unpopulate(val, "AllOf", &a.AllOf) + 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 { @@ -513,18 +753,19 @@ func (a *AlertRuleAllOfCondition) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type AlertRuleAnyOfOrLeafCondition. -func (a AlertRuleAnyOfOrLeafCondition) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type AlertRuleRecommendationResource. +func (a AlertRuleRecommendationResource) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "anyOf", a.AnyOf) - populate(objectMap, "containsAny", a.ContainsAny) - populate(objectMap, "equals", a.Equals) - populate(objectMap, "field", a.Field) + 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 AlertRuleAnyOfOrLeafCondition. -func (a *AlertRuleAnyOfOrLeafCondition) UnmarshalJSON(data []byte) error { +// 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) @@ -532,17 +773,20 @@ func (a *AlertRuleAnyOfOrLeafCondition) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "anyOf": - err = unpopulate(val, "AnyOf", &a.AnyOf) + case "id": + err = unpopulate(val, "ID", &a.ID) delete(rawMsg, key) - case "containsAny": - err = unpopulate(val, "ContainsAny", &a.ContainsAny) + case "name": + err = unpopulate(val, "Name", &a.Name) delete(rawMsg, key) - case "equals": - err = unpopulate(val, "Equals", &a.Equals) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) delete(rawMsg, key) - case "field": - err = unpopulate(val, "Field", &a.Field) + 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 { @@ -552,17 +796,16 @@ func (a *AlertRuleAnyOfOrLeafCondition) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type AlertRuleLeafCondition. -func (a AlertRuleLeafCondition) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type AlertRuleRecommendationsListResponse. +func (a AlertRuleRecommendationsListResponse) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "containsAny", a.ContainsAny) - populate(objectMap, "equals", a.Equals) - populate(objectMap, "field", a.Field) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type AlertRuleLeafCondition. -func (a *AlertRuleLeafCondition) UnmarshalJSON(data []byte) error { +// 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) @@ -570,14 +813,11 @@ func (a *AlertRuleLeafCondition) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "containsAny": - err = unpopulate(val, "ContainsAny", &a.ContainsAny) - delete(rawMsg, key) - case "equals": - err = unpopulate(val, "Equals", &a.Equals) + case "nextLink": + err = unpopulate(val, "NextLink", &a.NextLink) delete(rawMsg, key) - case "field": - err = unpopulate(val, "Field", &a.Field) + case "value": + err = unpopulate(val, "Value", &a.Value) delete(rawMsg, key) } if err != nil { @@ -587,20 +827,16 @@ func (a *AlertRuleLeafCondition) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type AlertRuleProperties. -func (a AlertRuleProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type AlertsList. +func (a AlertsList) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "actions", a.Actions) - populate(objectMap, "condition", a.Condition) - populate(objectMap, "description", a.Description) - populate(objectMap, "enabled", a.Enabled) - populate(objectMap, "scopes", a.Scopes) - populate(objectMap, "tenantScope", a.TenantScope) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type AlertRuleProperties. -func (a *AlertRuleProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type AlertsList. +func (a *AlertsList) 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) @@ -608,23 +844,11 @@ func (a *AlertRuleProperties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "actions": - err = unpopulate(val, "Actions", &a.Actions) - delete(rawMsg, key) - case "condition": - err = unpopulate(val, "Condition", &a.Condition) - delete(rawMsg, key) - case "description": - err = unpopulate(val, "Description", &a.Description) - delete(rawMsg, key) - case "enabled": - err = unpopulate(val, "Enabled", &a.Enabled) - delete(rawMsg, key) - case "scopes": - err = unpopulate(val, "Scopes", &a.Scopes) + case "nextLink": + err = unpopulate(val, "NextLink", &a.NextLink) delete(rawMsg, key) - case "tenantScope": - err = unpopulate(val, "TenantScope", &a.TenantScope) + case "value": + err = unpopulate(val, "Value", &a.Value) delete(rawMsg, key) } if err != nil { @@ -634,17 +858,15 @@ func (a *AlertRuleProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type AlertRuleRecommendationProperties. -func (a AlertRuleRecommendationProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type AlertsMetaData. +func (a AlertsMetaData) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "alertRuleType", a.AlertRuleType) - populate(objectMap, "displayInformation", a.DisplayInformation) - populate(objectMap, "ruleArmTemplate", a.RuleArmTemplate) + populate(objectMap, "properties", a.Properties) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type AlertRuleRecommendationProperties. -func (a *AlertRuleRecommendationProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type AlertsMetaData. +func (a *AlertsMetaData) 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) @@ -652,14 +874,35 @@ func (a *AlertRuleRecommendationProperties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "alertRuleType": - err = unpopulate(val, "AlertRuleType", &a.AlertRuleType) - delete(rawMsg, key) - case "displayInformation": - err = unpopulate(val, "DisplayInformation", &a.DisplayInformation) + case "properties": + a.Properties, err = unmarshalAlertsMetaDataPropertiesClassification(val) delete(rawMsg, key) - case "ruleArmTemplate": - err = unpopulate(val, "RuleArmTemplate", &a.RuleArmTemplate) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AlertsMetaDataProperties. +func (a AlertsMetaDataProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["metadataIdentifier"] = a.MetadataIdentifier + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AlertsMetaDataProperties. +func (a *AlertsMetaDataProperties) 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 "metadataIdentifier": + err = unpopulate(val, "MetadataIdentifier", &a.MetadataIdentifier) delete(rawMsg, key) } if err != nil { @@ -669,19 +912,18 @@ func (a *AlertRuleRecommendationProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type AlertRuleRecommendationResource. -func (a AlertRuleRecommendationResource) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type AlertsSummary. +func (a AlertsSummary) 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 { +// UnmarshalJSON implements the json.Unmarshaller interface for type AlertsSummary. +func (a *AlertsSummary) 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) @@ -698,9 +940,6 @@ func (a *AlertRuleRecommendationResource) UnmarshalJSON(data []byte) error { 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) @@ -712,16 +951,18 @@ func (a *AlertRuleRecommendationResource) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type AlertRuleRecommendationsListResponse. -func (a AlertRuleRecommendationsListResponse) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type AlertsSummaryGroup. +func (a AlertsSummaryGroup) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", a.NextLink) - populate(objectMap, "value", a.Value) + populate(objectMap, "groupedby", a.Groupedby) + populate(objectMap, "smartGroupsCount", a.SmartGroupsCount) + populate(objectMap, "total", a.Total) + populate(objectMap, "values", a.Values) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type AlertRuleRecommendationsListResponse. -func (a *AlertRuleRecommendationsListResponse) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type AlertsSummaryGroup. +func (a *AlertsSummaryGroup) 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) @@ -729,11 +970,17 @@ func (a *AlertRuleRecommendationsListResponse) UnmarshalJSON(data []byte) error for key, val := range rawMsg { var err error switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &a.NextLink) + case "groupedby": + err = unpopulate(val, "Groupedby", &a.Groupedby) delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &a.Value) + case "smartGroupsCount": + err = unpopulate(val, "SmartGroupsCount", &a.SmartGroupsCount) + delete(rawMsg, key) + case "total": + err = unpopulate(val, "Total", &a.Total) + delete(rawMsg, key) + case "values": + err = unpopulate(val, "Values", &a.Values) delete(rawMsg, key) } if err != nil { @@ -743,16 +990,18 @@ func (a *AlertRuleRecommendationsListResponse) UnmarshalJSON(data []byte) error return nil } -// MarshalJSON implements the json.Marshaller interface for type AlertsList. -func (a AlertsList) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type AlertsSummaryGroupItem. +func (a AlertsSummaryGroupItem) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", a.NextLink) - populate(objectMap, "value", a.Value) + populate(objectMap, "count", a.Count) + populate(objectMap, "groupedby", a.Groupedby) + populate(objectMap, "name", a.Name) + populate(objectMap, "values", a.Values) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type AlertsList. -func (a *AlertsList) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type AlertsSummaryGroupItem. +func (a *AlertsSummaryGroupItem) 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) @@ -760,11 +1009,17 @@ func (a *AlertsList) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &a.NextLink) + case "count": + err = unpopulate(val, "Count", &a.Count) delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &a.Value) + case "groupedby": + err = unpopulate(val, "Groupedby", &a.Groupedby) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "values": + err = unpopulate(val, "Values", &a.Values) delete(rawMsg, key) } if err != nil { @@ -774,15 +1029,16 @@ func (a *AlertsList) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type AlertsMetaData. -func (a AlertsMetaData) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type AnomalyRange. +func (a AnomalyRange) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "properties", a.Properties) + populateDateTimeRFC3339(objectMap, "end", a.End) + populateDateTimeRFC3339(objectMap, "start", a.Start) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type AlertsMetaData. -func (a *AlertsMetaData) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type AnomalyRange. +func (a *AnomalyRange) 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) @@ -790,8 +1046,11 @@ func (a *AlertsMetaData) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "properties": - a.Properties, err = unmarshalAlertsMetaDataPropertiesClassification(val) + case "end": + err = unpopulateDateTimeRFC3339(val, "End", &a.End) + delete(rawMsg, key) + case "start": + err = unpopulateDateTimeRFC3339(val, "Start", &a.Start) delete(rawMsg, key) } if err != nil { @@ -801,15 +1060,18 @@ func (a *AlertsMetaData) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type AlertsMetaDataProperties. -func (a AlertsMetaDataProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type AzureMetricAnomalyInsight. +func (a AzureMetricAnomalyInsight) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - objectMap["metadataIdentifier"] = a.MetadataIdentifier + populate(objectMap, "anomalyDirection", a.AnomalyDirection) + populate(objectMap, "anomalyScanRange", a.AnomalyScanRange) + populateDateTimeRFC3339(objectMap, "anomalyTime", a.AnomalyTime) + populate(objectMap, "thresholds", a.Thresholds) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type AlertsMetaDataProperties. -func (a *AlertsMetaDataProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type AzureMetricAnomalyInsight. +func (a *AzureMetricAnomalyInsight) 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) @@ -817,8 +1079,17 @@ func (a *AlertsMetaDataProperties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "metadataIdentifier": - err = unpopulate(val, "MetadataIdentifier", &a.MetadataIdentifier) + case "anomalyDirection": + err = unpopulate(val, "AnomalyDirection", &a.AnomalyDirection) + delete(rawMsg, key) + case "anomalyScanRange": + err = unpopulate(val, "AnomalyScanRange", &a.AnomalyScanRange) + delete(rawMsg, key) + case "anomalyTime": + err = unpopulateDateTimeRFC3339(val, "AnomalyTime", &a.AnomalyTime) + delete(rawMsg, key) + case "thresholds": + err = unpopulate(val, "Thresholds", &a.Thresholds) delete(rawMsg, key) } if err != nil { @@ -828,18 +1099,20 @@ func (a *AlertsMetaDataProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type AlertsSummary. -func (a AlertsSummary) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type AzureMetricData. +func (a AzureMetricData) 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, "type", a.Type) + populate(objectMap, "dimensions", a.Dimensions) + populate(objectMap, "metricAggregation", a.MetricAggregation) + populate(objectMap, "metricInterval", a.MetricInterval) + populate(objectMap, "metricName", a.MetricName) + populate(objectMap, "metricNamespace", a.MetricNamespace) + populate(objectMap, "scanRange", a.ScanRange) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type AlertsSummary. -func (a *AlertsSummary) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type AzureMetricData. +func (a *AzureMetricData) 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) @@ -847,17 +1120,23 @@ func (a *AlertsSummary) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "id": - err = unpopulate(val, "ID", &a.ID) + case "dimensions": + err = unpopulate(val, "Dimensions", &a.Dimensions) delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &a.Name) + case "metricAggregation": + err = unpopulate(val, "MetricAggregation", &a.MetricAggregation) delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &a.Properties) + case "metricInterval": + err = unpopulate(val, "MetricInterval", &a.MetricInterval) delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &a.Type) + case "metricName": + err = unpopulate(val, "MetricName", &a.MetricName) + delete(rawMsg, key) + case "metricNamespace": + err = unpopulate(val, "MetricNamespace", &a.MetricNamespace) + delete(rawMsg, key) + case "scanRange": + err = unpopulate(val, "ScanRange", &a.ScanRange) delete(rawMsg, key) } if err != nil { @@ -867,18 +1146,19 @@ func (a *AlertsSummary) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type AlertsSummaryGroup. -func (a AlertsSummaryGroup) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type AzureMetricDetails. +func (a AzureMetricDetails) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "groupedby", a.Groupedby) - populate(objectMap, "smartGroupsCount", a.SmartGroupsCount) - populate(objectMap, "total", a.Total) - populate(objectMap, "values", a.Values) + populate(objectMap, "category", a.Category) + populate(objectMap, "data", a.Data) + objectMap["detailsType"] = DetailsTypeAzureMetric + populate(objectMap, "insight", a.Insight) + populate(objectMap, "resourceIds", a.ResourceIDs) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type AlertsSummaryGroup. -func (a *AlertsSummaryGroup) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type AzureMetricDetails. +func (a *AzureMetricDetails) 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) @@ -886,17 +1166,20 @@ func (a *AlertsSummaryGroup) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "groupedby": - err = unpopulate(val, "Groupedby", &a.Groupedby) + case "category": + err = unpopulate(val, "Category", &a.Category) delete(rawMsg, key) - case "smartGroupsCount": - err = unpopulate(val, "SmartGroupsCount", &a.SmartGroupsCount) + case "data": + err = unpopulate(val, "Data", &a.Data) delete(rawMsg, key) - case "total": - err = unpopulate(val, "Total", &a.Total) + case "detailsType": + err = unpopulate(val, "DetailsType", &a.DetailsType) delete(rawMsg, key) - case "values": - err = unpopulate(val, "Values", &a.Values) + case "insight": + err = unpopulate(val, "Insight", &a.Insight) + delete(rawMsg, key) + case "resourceIds": + err = unpopulate(val, "ResourceIDs", &a.ResourceIDs) delete(rawMsg, key) } if err != nil { @@ -906,40 +1189,32 @@ func (a *AlertsSummaryGroup) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type AlertsSummaryGroupItem. -func (a AlertsSummaryGroupItem) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type BaselineRange. +func (b BaselineRange) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "count", a.Count) - populate(objectMap, "groupedby", a.Groupedby) - populate(objectMap, "name", a.Name) - populate(objectMap, "values", a.Values) + populate(objectMap, "high", b.High) + populate(objectMap, "low", b.Low) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type AlertsSummaryGroupItem. -func (a *AlertsSummaryGroupItem) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type BaselineRange. +func (b *BaselineRange) 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) + return fmt.Errorf("unmarshalling type %T: %v", b, err) } for key, val := range rawMsg { var err error switch key { - case "count": - err = unpopulate(val, "Count", &a.Count) - delete(rawMsg, key) - case "groupedby": - err = unpopulate(val, "Groupedby", &a.Groupedby) + case "high": + err = unpopulate(val, "High", &b.High) delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &a.Name) - delete(rawMsg, key) - case "values": - err = unpopulate(val, "Values", &a.Values) + case "low": + err = unpopulate(val, "Low", &b.Low) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) + return fmt.Errorf("unmarshalling type %T: %v", b, err) } } return nil @@ -1007,6 +1282,41 @@ func (c *Condition) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type CorrelationDetails. +func (c CorrelationDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "alertProcessingRule", c.AlertProcessingRule) + populateDateTimeRFC3339(objectMap, "correlationDateTime", c.CorrelationDateTime) + populate(objectMap, "parentAlertId", c.ParentAlertID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CorrelationDetails. +func (c *CorrelationDetails) 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 "alertProcessingRule": + err = unpopulate(val, "AlertProcessingRule", &c.AlertProcessingRule) + delete(rawMsg, key) + case "correlationDateTime": + err = unpopulateDateTimeRFC3339(val, "CorrelationDateTime", &c.CorrelationDateTime) + delete(rawMsg, key) + case "parentAlertId": + err = unpopulate(val, "ParentAlertID", &c.ParentAlertID) + 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) @@ -1042,51 +1352,199 @@ func (d *DailyRecurrence) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type Essentials. -func (e Essentials) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type DetailsBase. +func (d DetailsBase) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "actionStatus", e.ActionStatus) - populate(objectMap, "alertRule", e.AlertRule) - populate(objectMap, "alertState", e.AlertState) - populate(objectMap, "description", e.Description) - populateDateTimeRFC3339(objectMap, "lastModifiedDateTime", e.LastModifiedDateTime) - populate(objectMap, "lastModifiedUserName", e.LastModifiedUserName) - populate(objectMap, "monitorCondition", e.MonitorCondition) - populateDateTimeRFC3339(objectMap, "monitorConditionResolvedDateTime", e.MonitorConditionResolvedDateTime) - populate(objectMap, "monitorService", e.MonitorService) - populate(objectMap, "severity", e.Severity) - populate(objectMap, "signalType", e.SignalType) - populate(objectMap, "smartGroupId", e.SmartGroupID) - populate(objectMap, "smartGroupingReason", e.SmartGroupingReason) - populate(objectMap, "sourceCreatedId", e.SourceCreatedID) - populateDateTimeRFC3339(objectMap, "startDateTime", e.StartDateTime) - populate(objectMap, "targetResource", e.TargetResource) - populate(objectMap, "targetResourceGroup", e.TargetResourceGroup) - populate(objectMap, "targetResourceName", e.TargetResourceName) - populate(objectMap, "targetResourceType", e.TargetResourceType) + populate(objectMap, "category", d.Category) + objectMap["detailsType"] = d.DetailsType + populate(objectMap, "resourceIds", d.ResourceIDs) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type Essentials. -func (e *Essentials) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type DetailsBase. +func (d *DetailsBase) 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", d, err) } for key, val := range rawMsg { var err error switch key { - case "actionStatus": - err = unpopulate(val, "ActionStatus", &e.ActionStatus) + case "category": + err = unpopulate(val, "Category", &d.Category) delete(rawMsg, key) - case "alertRule": - err = unpopulate(val, "AlertRule", &e.AlertRule) + case "detailsType": + err = unpopulate(val, "DetailsType", &d.DetailsType) delete(rawMsg, key) - case "alertState": - err = unpopulate(val, "AlertState", &e.AlertState) + case "resourceIds": + err = unpopulate(val, "ResourceIDs", &d.ResourceIDs) delete(rawMsg, key) - case "description": - err = unpopulate(val, "Description", &e.Description) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DiagnosticsInsight. +func (d DiagnosticsInsight) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "content", d.Content) + populate(objectMap, "solutionId", d.SolutionID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DiagnosticsInsight. +func (d *DiagnosticsInsight) 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 "content": + err = unpopulate(val, "Content", &d.Content) + delete(rawMsg, key) + case "solutionId": + err = unpopulate(val, "SolutionID", &d.SolutionID) + 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 DiagnosticsSolutionDetails. +func (d DiagnosticsSolutionDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "category", d.Category) + objectMap["detailsType"] = DetailsTypeDiagnostics + populate(objectMap, "insight", d.Insight) + populate(objectMap, "resourceIds", d.ResourceIDs) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DiagnosticsSolutionDetails. +func (d *DiagnosticsSolutionDetails) 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 "category": + err = unpopulate(val, "Category", &d.Category) + delete(rawMsg, key) + case "detailsType": + err = unpopulate(val, "DetailsType", &d.DetailsType) + delete(rawMsg, key) + case "insight": + err = unpopulate(val, "Insight", &d.Insight) + delete(rawMsg, key) + case "resourceIds": + err = unpopulate(val, "ResourceIDs", &d.ResourceIDs) + 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 DimensionNameAndValue. +func (d DimensionNameAndValue) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", d.Name) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DimensionNameAndValue. +func (d *DimensionNameAndValue) 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 "name": + err = unpopulate(val, "Name", &d.Name) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &d.Value) + 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 Essentials. +func (e Essentials) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actionStatus", e.ActionStatus) + populate(objectMap, "alertRule", e.AlertRule) + populate(objectMap, "alertState", e.AlertState) + populate(objectMap, "correlationDetails", e.CorrelationDetails) + populate(objectMap, "description", e.Description) + populate(objectMap, "hasEnrichments", e.HasEnrichments) + populate(objectMap, "isStatefulAlert", e.IsStatefulAlert) + populateDateTimeRFC3339(objectMap, "lastModifiedDateTime", e.LastModifiedDateTime) + populate(objectMap, "lastModifiedUserName", e.LastModifiedUserName) + populate(objectMap, "monitorCondition", e.MonitorCondition) + populateDateTimeRFC3339(objectMap, "monitorConditionResolvedDateTime", e.MonitorConditionResolvedDateTime) + populate(objectMap, "monitorService", e.MonitorService) + populate(objectMap, "severity", e.Severity) + populate(objectMap, "signalType", e.SignalType) + populate(objectMap, "smartGroupId", e.SmartGroupID) + populate(objectMap, "smartGroupingReason", e.SmartGroupingReason) + populate(objectMap, "sourceCreatedId", e.SourceCreatedID) + populateDateTimeRFC3339(objectMap, "startDateTime", e.StartDateTime) + populate(objectMap, "targetResource", e.TargetResource) + populate(objectMap, "targetResourceGroup", e.TargetResourceGroup) + populate(objectMap, "targetResourceName", e.TargetResourceName) + populate(objectMap, "targetResourceType", e.TargetResourceType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Essentials. +func (e *Essentials) 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 "actionStatus": + err = unpopulate(val, "ActionStatus", &e.ActionStatus) + delete(rawMsg, key) + case "alertRule": + err = unpopulate(val, "AlertRule", &e.AlertRule) + delete(rawMsg, key) + case "alertState": + err = unpopulate(val, "AlertState", &e.AlertState) + delete(rawMsg, key) + case "correlationDetails": + err = unpopulate(val, "CorrelationDetails", &e.CorrelationDetails) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &e.Description) + delete(rawMsg, key) + case "hasEnrichments": + err = unpopulate(val, "HasEnrichments", &e.HasEnrichments) + delete(rawMsg, key) + case "isStatefulAlert": + err = unpopulate(val, "IsStatefulAlert", &e.IsStatefulAlert) delete(rawMsg, key) case "lastModifiedDateTime": err = unpopulateDateTimeRFC3339(val, "LastModifiedDateTime", &e.LastModifiedDateTime) @@ -1141,279 +1599,1655 @@ func (e *Essentials) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type MonitorServiceDetails. -func (m MonitorServiceDetails) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type EvaluatedPeriod. +func (e EvaluatedPeriod) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "displayName", m.DisplayName) - populate(objectMap, "name", m.Name) + populate(objectMap, "highThreshold", e.HighThreshold) + populate(objectMap, "lowThreshold", e.LowThreshold) + populate(objectMap, "metricValue", e.MetricValue) + populate(objectMap, "thresholdMet", e.ThresholdMet) + populateDateTimeRFC3339(objectMap, "timestamp", e.Timestamp) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type MonitorServiceDetails. -func (m *MonitorServiceDetails) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type EvaluatedPeriod. +func (e *EvaluatedPeriod) 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", e, err) } for key, val := range rawMsg { var err error switch key { - case "displayName": - err = unpopulate(val, "DisplayName", &m.DisplayName) + case "highThreshold": + err = unpopulate(val, "HighThreshold", &e.HighThreshold) delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &m.Name) + case "lowThreshold": + err = unpopulate(val, "LowThreshold", &e.LowThreshold) + delete(rawMsg, key) + case "metricValue": + err = unpopulate(val, "MetricValue", &e.MetricValue) + delete(rawMsg, key) + case "thresholdMet": + err = unpopulate(val, "ThresholdMet", &e.ThresholdMet) + delete(rawMsg, key) + case "timestamp": + err = unpopulateDateTimeRFC3339(val, "Timestamp", &e.Timestamp) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", m, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type MonitorServiceList. -func (m MonitorServiceList) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type Evaluation. +func (e Evaluation) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "data", m.Data) - objectMap["metadataIdentifier"] = MetadataIdentifierMonitorServiceList + populate(objectMap, "alertState", e.AlertState) + populate(objectMap, "evaluatedPeriods", e.EvaluatedPeriods) + populateDateTimeRFC3339(objectMap, "evaluationTime", e.EvaluationTime) + populate(objectMap, "thresholdMet", e.ThresholdMet) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type MonitorServiceList. -func (m *MonitorServiceList) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type Evaluation. +func (e *Evaluation) 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", e, err) } for key, val := range rawMsg { var err error switch key { - case "data": - err = unpopulate(val, "Data", &m.Data) + case "alertState": + err = unpopulate(val, "AlertState", &e.AlertState) delete(rawMsg, key) - case "metadataIdentifier": - err = unpopulate(val, "MetadataIdentifier", &m.MetadataIdentifier) + case "evaluatedPeriods": + err = unpopulate(val, "EvaluatedPeriods", &e.EvaluatedPeriods) + delete(rawMsg, key) + case "evaluationTime": + err = unpopulateDateTimeRFC3339(val, "EvaluationTime", &e.EvaluationTime) + delete(rawMsg, key) + case "thresholdMet": + err = unpopulate(val, "ThresholdMet", &e.ThresholdMet) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", m, err) + return fmt.Errorf("unmarshalling type %T: %v", e, 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 ExceptionPatternAnomaly. +func (e ExceptionPatternAnomaly) 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, "count", e.Count) + populate(objectMap, "generatedMessage", e.GeneratedMessage) + populate(objectMap, "itemId", e.ItemID) + populate(objectMap, "problemId", e.ProblemID) 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 ExceptionPatternAnomaly. +func (e *ExceptionPatternAnomaly) 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", e, err) } for key, val := range rawMsg { var err error switch key { - case "daysOfMonth": - err = unpopulate(val, "DaysOfMonth", &m.DaysOfMonth) + case "count": + err = unpopulate(val, "Count", &e.Count) delete(rawMsg, key) - case "endTime": - err = unpopulate(val, "EndTime", &m.EndTime) + case "generatedMessage": + err = unpopulate(val, "GeneratedMessage", &e.GeneratedMessage) delete(rawMsg, key) - case "recurrenceType": - err = unpopulate(val, "RecurrenceType", &m.RecurrenceType) + case "itemId": + err = unpopulate(val, "ItemID", &e.ItemID) delete(rawMsg, key) - case "startTime": - err = unpopulate(val, "StartTime", &m.StartTime) + case "problemId": + err = unpopulate(val, "ProblemID", &e.ProblemID) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", m, err) + return fmt.Errorf("unmarshalling type %T: %v", e, 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 FetchInvestigationResultParameters. +func (f FetchInvestigationResultParameters) 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, "investigationId", f.InvestigationID) 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 FetchInvestigationResultParameters. +func (f *FetchInvestigationResultParameters) 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", f, 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 "investigationId": + err = unpopulate(val, "InvestigationID", &f.InvestigationID) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) + return fmt.Errorf("unmarshalling type %T: %v", f, 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 InvestigationDetails. +func (i InvestigationDetails) 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, "category", i.Category) + populate(objectMap, "data", i.Data) + objectMap["detailsType"] = DetailsTypeInvestigation + populate(objectMap, "resourceIds", i.ResourceIDs) 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 InvestigationDetails. +func (i *InvestigationDetails) 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", i, err) } for key, val := range rawMsg { var err error switch key { - case "description": - err = unpopulate(val, "Description", &o.Description) + case "category": + err = unpopulate(val, "Category", &i.Category) delete(rawMsg, key) - case "operation": - err = unpopulate(val, "Operation", &o.Operation) + case "data": + err = unpopulate(val, "Data", &i.Data) delete(rawMsg, key) - case "provider": - err = unpopulate(val, "Provider", &o.Provider) + case "detailsType": + err = unpopulate(val, "DetailsType", &i.DetailsType) delete(rawMsg, key) - case "resource": - err = unpopulate(val, "Resource", &o.Resource) + case "resourceIds": + err = unpopulate(val, "ResourceIDs", &i.ResourceIDs) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) + return fmt.Errorf("unmarshalling type %T: %v", i, 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 InvestigationEntity. +func (i InvestigationEntity) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", o.NextLink) - populate(objectMap, "value", o.Value) + populate(objectMap, "children", i.Children) + populateDateTimeRFC3339(objectMap, "createdAt", i.CreatedAt) + populate(objectMap, "details", i.Details) + populate(objectMap, "entityType", i.EntityType) + populate(objectMap, "execution", i.Execution) + populate(objectMap, "healthState", i.HealthState) + populate(objectMap, "id", i.ID) + populateDateTimeRFC3339(objectMap, "lastModifiedAt", i.LastModifiedAt) + populate(objectMap, "origin", i.Origin) + populate(objectMap, "relevance", i.Relevance) + populate(objectMap, "summary", i.Summary) 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 InvestigationEntity. +func (i *InvestigationEntity) 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", i, err) } for key, val := range rawMsg { var err error switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &o.NextLink) + case "children": + err = unpopulate(val, "Children", &i.Children) delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &o.Value) + case "createdAt": + err = unpopulateDateTimeRFC3339(val, "CreatedAt", &i.CreatedAt) + delete(rawMsg, key) + case "details": + i.Details, err = unmarshalDetailsBaseClassification(val) + delete(rawMsg, key) + case "entityType": + err = unpopulate(val, "EntityType", &i.EntityType) + delete(rawMsg, key) + case "execution": + err = unpopulate(val, "Execution", &i.Execution) + delete(rawMsg, key) + case "healthState": + err = unpopulate(val, "HealthState", &i.HealthState) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &i.ID) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateDateTimeRFC3339(val, "LastModifiedAt", &i.LastModifiedAt) + delete(rawMsg, key) + case "origin": + err = unpopulate(val, "Origin", &i.Origin) + delete(rawMsg, key) + case "relevance": + err = unpopulate(val, "Relevance", &i.Relevance) + delete(rawMsg, key) + case "summary": + err = unpopulate(val, "Summary", &i.Summary) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) + return fmt.Errorf("unmarshalling type %T: %v", i, 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 InvestigationExecution. +func (i InvestigationExecution) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "properties", p.Properties) - populate(objectMap, "tags", p.Tags) + populateDateTimeRFC3339(objectMap, "completedAt", i.CompletedAt) + populate(objectMap, "runState", i.RunState) 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 InvestigationExecution. +func (i *InvestigationExecution) 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) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } for key, val := range rawMsg { var err error switch key { - case "properties": - err = unpopulate(val, "Properties", &p.Properties) + case "completedAt": + err = unpopulateDateTimeRFC3339(val, "CompletedAt", &i.CompletedAt) delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &p.Tags) + case "runState": + err = unpopulate(val, "RunState", &i.RunState) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } } 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 InvestigationMetadata. +func (i InvestigationMetadata) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "enabled", p.Enabled) + populateDateTimeRFC3339(objectMap, "createdAt", i.CreatedAt) + populate(objectMap, "execution", i.Execution) + populate(objectMap, "id", i.ID) + populate(objectMap, "runParameters", i.RunParameters) 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 InvestigationMetadata. +func (i *InvestigationMetadata) 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) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } for key, val := range rawMsg { var err error switch key { - case "enabled": - err = unpopulate(val, "Enabled", &p.Enabled) + case "createdAt": + err = unpopulateDateTimeRFC3339(val, "CreatedAt", &i.CreatedAt) + delete(rawMsg, key) + case "execution": + err = unpopulate(val, "Execution", &i.Execution) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &i.ID) + delete(rawMsg, key) + case "runParameters": + err = unpopulate(val, "RunParameters", &i.RunParameters) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type PrometheusRule. -func (p PrometheusRule) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type InvestigationResult. +func (i InvestigationResult) 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, "children", i.Children) + populateDateTimeRFC3339(objectMap, "createdAt", i.CreatedAt) + populate(objectMap, "entityType", i.EntityType) + populate(objectMap, "execution", i.Execution) + populate(objectMap, "id", i.ID) + populateDateTimeRFC3339(objectMap, "lastModifiedAt", i.LastModifiedAt) + populate(objectMap, "origin", i.Origin) + populate(objectMap, "runParameters", i.RunParameters) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type InvestigationResult. +func (i *InvestigationResult) 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", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "children": + err = unpopulate(val, "Children", &i.Children) + delete(rawMsg, key) + case "createdAt": + err = unpopulateDateTimeRFC3339(val, "CreatedAt", &i.CreatedAt) + delete(rawMsg, key) + case "entityType": + err = unpopulate(val, "EntityType", &i.EntityType) + delete(rawMsg, key) + case "execution": + err = unpopulate(val, "Execution", &i.Execution) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &i.ID) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateDateTimeRFC3339(val, "LastModifiedAt", &i.LastModifiedAt) + delete(rawMsg, key) + case "origin": + err = unpopulate(val, "Origin", &i.Origin) + delete(rawMsg, key) + case "runParameters": + err = unpopulate(val, "RunParameters", &i.RunParameters) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type InvestigationScope. +func (i InvestigationScope) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", i.ID) + populate(objectMap, "origin", i.Origin) + populate(objectMap, "relevance", i.Relevance) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type InvestigationScope. +func (i *InvestigationScope) 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", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &i.ID) + delete(rawMsg, key) + case "origin": + err = unpopulate(val, "Origin", &i.Origin) + delete(rawMsg, key) + case "relevance": + err = unpopulate(val, "Relevance", &i.Relevance) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type IssueProperties. +func (i IssueProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "impactTime", i.ImpactTime) + populate(objectMap, "investigations", i.Investigations) + populate(objectMap, "investigationsCount", i.InvestigationsCount) + populate(objectMap, "provisioningState", i.ProvisioningState) + populate(objectMap, "severity", i.Severity) + populate(objectMap, "status", i.Status) + populate(objectMap, "title", i.Title) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IssueProperties. +func (i *IssueProperties) 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", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "impactTime": + err = unpopulateDateTimeRFC3339(val, "ImpactTime", &i.ImpactTime) + delete(rawMsg, key) + case "investigations": + err = unpopulate(val, "Investigations", &i.Investigations) + delete(rawMsg, key) + case "investigationsCount": + err = unpopulate(val, "InvestigationsCount", &i.InvestigationsCount) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &i.ProvisioningState) + delete(rawMsg, key) + case "severity": + err = unpopulate(val, "Severity", &i.Severity) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &i.Status) + delete(rawMsg, key) + case "title": + err = unpopulate(val, "Title", &i.Title) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type IssuePropertiesUpdate. +func (i IssuePropertiesUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "impactTime", i.ImpactTime) + populate(objectMap, "severity", i.Severity) + populate(objectMap, "status", i.Status) + populate(objectMap, "title", i.Title) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IssuePropertiesUpdate. +func (i *IssuePropertiesUpdate) 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", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "impactTime": + err = unpopulateDateTimeRFC3339(val, "ImpactTime", &i.ImpactTime) + delete(rawMsg, key) + case "severity": + err = unpopulate(val, "Severity", &i.Severity) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &i.Status) + delete(rawMsg, key) + case "title": + err = unpopulate(val, "Title", &i.Title) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type IssueResource. +func (i IssueResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", i.ID) + populate(objectMap, "name", i.Name) + populate(objectMap, "properties", i.Properties) + populate(objectMap, "systemData", i.SystemData) + populate(objectMap, "type", i.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IssueResource. +func (i *IssueResource) 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", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &i.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &i.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &i.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &i.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &i.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type IssueResourceListResult. +func (i IssueResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", i.NextLink) + populate(objectMap, "value", i.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IssueResourceListResult. +func (i *IssueResourceListResult) 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", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &i.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &i.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type IssueResourceUpdate. +func (i IssueResourceUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", i.ID) + populate(objectMap, "name", i.Name) + populate(objectMap, "properties", i.Properties) + populate(objectMap, "systemData", i.SystemData) + populate(objectMap, "type", i.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IssueResourceUpdate. +func (i *IssueResourceUpdate) 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", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &i.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &i.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &i.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &i.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &i.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ListParameter. +func (l ListParameter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "filter", l.Filter) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ListParameter. +func (l *ListParameter) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "filter": + err = unpopulate(val, "Filter", &l.Filter) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type LogAlertRuleCondition. +func (l LogAlertRuleCondition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "alertSensitivity", l.AlertSensitivity) + populate(objectMap, "criterionType", l.CriterionType) + populate(objectMap, "dimensions", l.Dimensions) + populate(objectMap, "failingPeriods", l.FailingPeriods) + populateDateTimeRFC3339(objectMap, "ignoreDataBefore", l.IgnoreDataBefore) + populate(objectMap, "metricMeasureColumn", l.MetricMeasureColumn) + populate(objectMap, "metricName", l.MetricName) + populate(objectMap, "operator", l.Operator) + populate(objectMap, "query", l.Query) + populate(objectMap, "resourceIdColumn", l.ResourceIDColumn) + populate(objectMap, "threshold", l.Threshold) + populate(objectMap, "timeAggregation", l.TimeAggregation) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LogAlertRuleCondition. +func (l *LogAlertRuleCondition) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "alertSensitivity": + err = unpopulate(val, "AlertSensitivity", &l.AlertSensitivity) + delete(rawMsg, key) + case "criterionType": + err = unpopulate(val, "CriterionType", &l.CriterionType) + delete(rawMsg, key) + case "dimensions": + err = unpopulate(val, "Dimensions", &l.Dimensions) + delete(rawMsg, key) + case "failingPeriods": + err = unpopulate(val, "FailingPeriods", &l.FailingPeriods) + delete(rawMsg, key) + case "ignoreDataBefore": + err = unpopulateDateTimeRFC3339(val, "IgnoreDataBefore", &l.IgnoreDataBefore) + delete(rawMsg, key) + case "metricMeasureColumn": + err = unpopulate(val, "MetricMeasureColumn", &l.MetricMeasureColumn) + delete(rawMsg, key) + case "metricName": + err = unpopulate(val, "MetricName", &l.MetricName) + delete(rawMsg, key) + case "operator": + err = unpopulate(val, "Operator", &l.Operator) + delete(rawMsg, key) + case "query": + err = unpopulate(val, "Query", &l.Query) + delete(rawMsg, key) + case "resourceIdColumn": + err = unpopulate(val, "ResourceIDColumn", &l.ResourceIDColumn) + delete(rawMsg, key) + case "threshold": + err = unpopulate(val, "Threshold", &l.Threshold) + delete(rawMsg, key) + case "timeAggregation": + err = unpopulate(val, "TimeAggregation", &l.TimeAggregation) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type LogAlertRuleConditionFailingPeriods. +func (l LogAlertRuleConditionFailingPeriods) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "minFailingPeriodsToAlert", l.MinFailingPeriodsToAlert) + populate(objectMap, "numberOfEvaluationPeriods", l.NumberOfEvaluationPeriods) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LogAlertRuleConditionFailingPeriods. +func (l *LogAlertRuleConditionFailingPeriods) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "minFailingPeriodsToAlert": + err = unpopulate(val, "MinFailingPeriodsToAlert", &l.MinFailingPeriodsToAlert) + delete(rawMsg, key) + case "numberOfEvaluationPeriods": + err = unpopulate(val, "NumberOfEvaluationPeriods", &l.NumberOfEvaluationPeriods) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type LogAlertRuleCriteria. +func (l LogAlertRuleCriteria) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "allOf", l.AllOf) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LogAlertRuleCriteria. +func (l *LogAlertRuleCriteria) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "allOf": + err = unpopulate(val, "AllOf", &l.AllOf) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type LogAlertRuleDimension. +func (l LogAlertRuleDimension) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", l.Name) + populate(objectMap, "operator", l.Operator) + populate(objectMap, "values", l.Values) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LogAlertRuleDimension. +func (l *LogAlertRuleDimension) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &l.Name) + delete(rawMsg, key) + case "operator": + err = unpopulate(val, "Operator", &l.Operator) + delete(rawMsg, key) + case "values": + err = unpopulate(val, "Values", &l.Values) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type LogAlertRuleProperties. +func (l LogAlertRuleProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "autoMitigate", l.AutoMitigate) + populate(objectMap, "checkWorkspaceAlertsStorageConfigured", l.CheckWorkspaceAlertsStorageConfigured) + populate(objectMap, "createdWithApiVersion", l.CreatedWithAPIVersion) + populate(objectMap, "criteria", l.Criteria) + populate(objectMap, "description", l.Description) + populate(objectMap, "displayName", l.DisplayName) + populate(objectMap, "enabled", l.Enabled) + populate(objectMap, "evaluationFrequency", l.EvaluationFrequency) + populate(objectMap, "isLegacyLogAnalyticsRule", l.IsLegacyLogAnalyticsRule) + populate(objectMap, "isWorkspaceAlertsStorageConfigured", l.IsWorkspaceAlertsStorageConfigured) + populate(objectMap, "muteActionsDuration", l.MuteActionsDuration) + populate(objectMap, "overrideQueryTimeRange", l.OverrideQueryTimeRange) + populate(objectMap, "resolveConfiguration", l.ResolveConfiguration) + populate(objectMap, "scopes", l.Scopes) + populate(objectMap, "severity", l.Severity) + populate(objectMap, "skipQueryValidation", l.SkipQueryValidation) + populate(objectMap, "targetResourceTypes", l.TargetResourceTypes) + populate(objectMap, "windowSize", l.WindowSize) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LogAlertRuleProperties. +func (l *LogAlertRuleProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "autoMitigate": + err = unpopulate(val, "AutoMitigate", &l.AutoMitigate) + delete(rawMsg, key) + case "checkWorkspaceAlertsStorageConfigured": + err = unpopulate(val, "CheckWorkspaceAlertsStorageConfigured", &l.CheckWorkspaceAlertsStorageConfigured) + delete(rawMsg, key) + case "createdWithApiVersion": + err = unpopulate(val, "CreatedWithAPIVersion", &l.CreatedWithAPIVersion) + delete(rawMsg, key) + case "criteria": + err = unpopulate(val, "Criteria", &l.Criteria) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &l.Description) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &l.DisplayName) + delete(rawMsg, key) + case "enabled": + err = unpopulate(val, "Enabled", &l.Enabled) + delete(rawMsg, key) + case "evaluationFrequency": + err = unpopulate(val, "EvaluationFrequency", &l.EvaluationFrequency) + delete(rawMsg, key) + case "isLegacyLogAnalyticsRule": + err = unpopulate(val, "IsLegacyLogAnalyticsRule", &l.IsLegacyLogAnalyticsRule) + delete(rawMsg, key) + case "isWorkspaceAlertsStorageConfigured": + err = unpopulate(val, "IsWorkspaceAlertsStorageConfigured", &l.IsWorkspaceAlertsStorageConfigured) + delete(rawMsg, key) + case "muteActionsDuration": + err = unpopulate(val, "MuteActionsDuration", &l.MuteActionsDuration) + delete(rawMsg, key) + case "overrideQueryTimeRange": + err = unpopulate(val, "OverrideQueryTimeRange", &l.OverrideQueryTimeRange) + delete(rawMsg, key) + case "resolveConfiguration": + err = unpopulate(val, "ResolveConfiguration", &l.ResolveConfiguration) + delete(rawMsg, key) + case "scopes": + err = unpopulate(val, "Scopes", &l.Scopes) + delete(rawMsg, key) + case "severity": + err = unpopulate(val, "Severity", &l.Severity) + delete(rawMsg, key) + case "skipQueryValidation": + err = unpopulate(val, "SkipQueryValidation", &l.SkipQueryValidation) + delete(rawMsg, key) + case "targetResourceTypes": + err = unpopulate(val, "TargetResourceTypes", &l.TargetResourceTypes) + delete(rawMsg, key) + case "windowSize": + err = unpopulate(val, "WindowSize", &l.WindowSize) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type LogAlertRuleResolveConfiguration. +func (l LogAlertRuleResolveConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "autoResolved", l.AutoResolved) + populate(objectMap, "timeToResolve", l.TimeToResolve) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LogAlertRuleResolveConfiguration. +func (l *LogAlertRuleResolveConfiguration) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "autoResolved": + err = unpopulate(val, "AutoResolved", &l.AutoResolved) + delete(rawMsg, key) + case "timeToResolve": + err = unpopulate(val, "TimeToResolve", &l.TimeToResolve) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type LogAlertRuleResource. +func (l LogAlertRuleResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "etag", l.Etag) + populate(objectMap, "id", l.ID) + populate(objectMap, "kind", l.Kind) + populate(objectMap, "location", l.Location) + populate(objectMap, "name", l.Name) + populate(objectMap, "properties", l.Properties) + populate(objectMap, "systemData", l.SystemData) + populate(objectMap, "tags", l.Tags) + populate(objectMap, "type", l.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LogAlertRuleResource. +func (l *LogAlertRuleResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "etag": + err = unpopulate(val, "Etag", &l.Etag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &l.ID) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &l.Kind) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &l.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &l.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &l.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &l.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &l.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &l.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MonitorServiceDetails. +func (m MonitorServiceDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "displayName", m.DisplayName) + populate(objectMap, "name", m.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MonitorServiceDetails. +func (m *MonitorServiceDetails) 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 "displayName": + err = unpopulate(val, "DisplayName", &m.DisplayName) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &m.Name) + 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 MonitorServiceList. +func (m MonitorServiceList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "data", m.Data) + objectMap["metadataIdentifier"] = MetadataIdentifierMonitorServiceList + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MonitorServiceList. +func (m *MonitorServiceList) 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 "data": + err = unpopulate(val, "Data", &m.Data) + delete(rawMsg, key) + 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 Origin. +func (o Origin) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "addedBy", o.AddedBy) + populate(objectMap, "addedByType", o.AddedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Origin. +func (o *Origin) 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 "addedBy": + err = unpopulate(val, "AddedBy", &o.AddedBy) + delete(rawMsg, key) + case "addedByType": + err = unpopulate(val, "AddedByType", &o.AddedByType) + 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 PagedRelatedAlert. +func (p PagedRelatedAlert) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PagedRelatedAlert. +func (p *PagedRelatedAlert) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &p.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &p.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PagedRelatedResource. +func (p PagedRelatedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PagedRelatedResource. +func (p *PagedRelatedResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &p.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &p.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type 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 PreviewAlertRuleRequest. +func (p PreviewAlertRuleRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "location", p.Location) + populate(objectMap, "properties", p.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PreviewAlertRuleRequest. +func (p *PreviewAlertRuleRequest) 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 "location": + err = unpopulate(val, "Location", &p.Location) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + 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 PreviewAlertRuleRequestProperties. +func (p PreviewAlertRuleRequestProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "alertRuleProperties", p.AlertRuleProperties) + populate(objectMap, "alertRuleType", p.AlertRuleType) + populate(objectMap, "lookbackPeriod", p.LookbackPeriod) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PreviewAlertRuleRequestProperties. +func (p *PreviewAlertRuleRequestProperties) 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 "alertRuleProperties": + err = unpopulate(val, "AlertRuleProperties", &p.AlertRuleProperties) + delete(rawMsg, key) + case "alertRuleType": + err = unpopulate(val, "AlertRuleType", &p.AlertRuleType) + delete(rawMsg, key) + case "lookbackPeriod": + err = unpopulate(val, "LookbackPeriod", &p.LookbackPeriod) + 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 PreviewAlertRuleResponse. +func (p PreviewAlertRuleResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "rulePreviewResults", p.RulePreviewResults) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PreviewAlertRuleResponse. +func (p *PreviewAlertRuleResponse) 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 "rulePreviewResults": + err = unpopulate(val, "RulePreviewResults", &p.RulePreviewResults) + 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) @@ -1421,8 +3255,146 @@ func (p PrometheusRule) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type PrometheusRule. -func (p *PrometheusRule) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type PrometheusRule. +func (p *PrometheusRule) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", 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", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PrometheusRuleGroupResource. +func (p PrometheusRuleGroupResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "location", p.Location) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "systemData", p.SystemData) + populate(objectMap, "tags", p.Tags) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrometheusRuleGroupResource. +func (p *PrometheusRuleGroupResource) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", p, err) @@ -1430,35 +3402,84 @@ func (p *PrometheusRule) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "actions": - err = unpopulate(val, "Actions", &p.Actions) + case "id": + err = unpopulate(val, "ID", &p.ID) delete(rawMsg, key) - case "alert": - err = unpopulate(val, "Alert", &p.Alert) + case "location": + err = unpopulate(val, "Location", &p.Location) delete(rawMsg, key) - case "annotations": - err = unpopulate(val, "Annotations", &p.Annotations) + case "name": + err = unpopulate(val, "Name", &p.Name) delete(rawMsg, key) - case "enabled": - err = unpopulate(val, "Enabled", &p.Enabled) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) delete(rawMsg, key) - case "expression": - err = unpopulate(val, "Expression", &p.Expression) + case "systemData": + err = unpopulate(val, "SystemData", &p.SystemData) delete(rawMsg, key) - case "for": - err = unpopulate(val, "For", &p.For) + case "tags": + err = unpopulate(val, "Tags", &p.Tags) delete(rawMsg, key) - case "labels": - err = unpopulate(val, "Labels", &p.Labels) + case "type": + err = unpopulate(val, "Type", &p.Type) delete(rawMsg, key) - case "record": - err = unpopulate(val, "Record", &p.Record) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PrometheusRuleGroupResourceCollection. +func (p PrometheusRuleGroupResourceCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrometheusRuleGroupResourceCollection. +func (p *PrometheusRuleGroupResourceCollection) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + err = unpopulate(val, "Value", &p.Value) delete(rawMsg, key) - case "resolveConfiguration": - err = unpopulate(val, "ResolveConfiguration", &p.ResolveConfiguration) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PrometheusRuleGroupResourcePatchParameters. +func (p PrometheusRuleGroupResourcePatchParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "tags", p.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrometheusRuleGroupResourcePatchParameters. +func (p *PrometheusRuleGroupResourcePatchParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &p.Properties) delete(rawMsg, key) - case "severity": - err = unpopulate(val, "Severity", &p.Severity) + case "tags": + err = unpopulate(val, "Tags", &p.Tags) delete(rawMsg, key) } if err != nil { @@ -1468,16 +3489,15 @@ func (p *PrometheusRule) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type PrometheusRuleGroupAction. -func (p PrometheusRuleGroupAction) 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, "actionGroupId", p.ActionGroupID) - populate(objectMap, "actionProperties", p.ActionProperties) + populate(objectMap, "enabled", p.Enabled) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type PrometheusRuleGroupAction. -func (p *PrometheusRuleGroupAction) 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", p, err) @@ -1485,11 +3505,39 @@ func (p *PrometheusRuleGroupAction) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "actionGroupId": - err = unpopulate(val, "ActionGroupID", &p.ActionGroupID) + case "enabled": + err = unpopulate(val, "Enabled", &p.Enabled) delete(rawMsg, key) - case "actionProperties": - err = unpopulate(val, "ActionProperties", &p.ActionProperties) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PrometheusRuleResolveConfiguration. +func (p PrometheusRuleResolveConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "autoResolved", p.AutoResolved) + populate(objectMap, "timeToResolve", p.TimeToResolve) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrometheusRuleResolveConfiguration. +func (p *PrometheusRuleResolveConfiguration) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "autoResolved": + err = unpopulate(val, "AutoResolved", &p.AutoResolved) + delete(rawMsg, key) + case "timeToResolve": + err = unpopulate(val, "TimeToResolve", &p.TimeToResolve) delete(rawMsg, key) } if err != nil { @@ -1499,231 +3547,321 @@ func (p *PrometheusRuleGroupAction) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type PrometheusRuleGroupProperties. -func (p PrometheusRuleGroupProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type Recurrence. +func (r Recurrence) 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) + populate(objectMap, "endTime", r.EndTime) + objectMap["recurrenceType"] = r.RecurrenceType + populate(objectMap, "startTime", r.StartTime) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Recurrence. +func (r *Recurrence) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "endTime": + err = unpopulate(val, "EndTime", &r.EndTime) + delete(rawMsg, key) + case "recurrenceType": + err = unpopulate(val, "RecurrenceType", &r.RecurrenceType) + delete(rawMsg, key) + case "startTime": + err = unpopulate(val, "StartTime", &r.StartTime) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RelatedAlert. +func (r RelatedAlert) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "addedAt", r.AddedAt) + populate(objectMap, "id", r.ID) + populateDateTimeRFC3339(objectMap, "lastModifiedAt", r.LastModifiedAt) + populate(objectMap, "origin", r.Origin) + populate(objectMap, "relevance", r.Relevance) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RelatedAlert. +func (r *RelatedAlert) 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 "addedAt": + err = unpopulateDateTimeRFC3339(val, "AddedAt", &r.AddedAt) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateDateTimeRFC3339(val, "LastModifiedAt", &r.LastModifiedAt) + delete(rawMsg, key) + case "origin": + err = unpopulate(val, "Origin", &r.Origin) + delete(rawMsg, key) + case "relevance": + err = unpopulate(val, "Relevance", &r.Relevance) + 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 RelatedAlertAnomalyInsight. +func (r RelatedAlertAnomalyInsight) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "anomalyTime", r.AnomalyTime) + populateDateTimeRFC3339(objectMap, "firedTime", r.FiredTime) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RelatedAlertAnomalyInsight. +func (r *RelatedAlertAnomalyInsight) 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 "anomalyTime": + err = unpopulateDateTimeRFC3339(val, "AnomalyTime", &r.AnomalyTime) + delete(rawMsg, key) + case "firedTime": + err = unpopulateDateTimeRFC3339(val, "FiredTime", &r.FiredTime) + 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 RelatedAlertData. +func (r RelatedAlertData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "firedAlertId", r.FiredAlertID) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type PrometheusRuleGroupProperties. -func (p *PrometheusRuleGroupProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type RelatedAlertData. +func (r *RelatedAlertData) 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) + return fmt.Errorf("unmarshalling type %T: %v", r, 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) + case "firedAlertId": + err = unpopulate(val, "FiredAlertID", &r.FiredAlertID) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", r, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type PrometheusRuleGroupResource. -func (p PrometheusRuleGroupResource) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type RelatedAlertDetails. +func (r RelatedAlertDetails) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", p.ID) - populate(objectMap, "location", p.Location) - populate(objectMap, "name", p.Name) - populate(objectMap, "properties", p.Properties) - populate(objectMap, "systemData", p.SystemData) - populate(objectMap, "tags", p.Tags) - populate(objectMap, "type", p.Type) + populate(objectMap, "category", r.Category) + populate(objectMap, "data", r.Data) + objectMap["detailsType"] = DetailsTypeRelatedAlert + populate(objectMap, "insight", r.Insight) + populate(objectMap, "resourceIds", r.ResourceIDs) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type PrometheusRuleGroupResource. -func (p *PrometheusRuleGroupResource) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type RelatedAlertDetails. +func (r *RelatedAlertDetails) 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) + 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", &p.ID) + case "category": + err = unpopulate(val, "Category", &r.Category) delete(rawMsg, key) - case "location": - err = unpopulate(val, "Location", &p.Location) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &p.Name) - delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &p.Properties) + case "data": + err = unpopulate(val, "Data", &r.Data) delete(rawMsg, key) - case "systemData": - err = unpopulate(val, "SystemData", &p.SystemData) + case "detailsType": + err = unpopulate(val, "DetailsType", &r.DetailsType) delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &p.Tags) + case "insight": + err = unpopulate(val, "Insight", &r.Insight) delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &p.Type) + case "resourceIds": + err = unpopulate(val, "ResourceIDs", &r.ResourceIDs) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", r, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type PrometheusRuleGroupResourceCollection. -func (p PrometheusRuleGroupResourceCollection) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type RelatedAlerts. +func (r RelatedAlerts) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "value", p.Value) + populate(objectMap, "value", r.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type PrometheusRuleGroupResourceCollection. -func (p *PrometheusRuleGroupResourceCollection) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type RelatedAlerts. +func (r *RelatedAlerts) 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) + return fmt.Errorf("unmarshalling type %T: %v", r, err) } for key, val := range rawMsg { var err error switch key { case "value": - err = unpopulate(val, "Value", &p.Value) + err = unpopulate(val, "Value", &r.Value) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", r, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type PrometheusRuleGroupResourcePatch. -func (p PrometheusRuleGroupResourcePatch) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type RelatedResource. +func (r RelatedResource) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "properties", p.Properties) - populate(objectMap, "tags", p.Tags) + populateDateTimeRFC3339(objectMap, "addedAt", r.AddedAt) + populate(objectMap, "id", r.ID) + populateDateTimeRFC3339(objectMap, "lastModifiedAt", r.LastModifiedAt) + populate(objectMap, "origin", r.Origin) + populate(objectMap, "relevance", r.Relevance) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type PrometheusRuleGroupResourcePatch. -func (p *PrometheusRuleGroupResourcePatch) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type RelatedResource. +func (r *RelatedResource) 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) + return fmt.Errorf("unmarshalling type %T: %v", r, err) } for key, val := range rawMsg { var err error switch key { - case "properties": - err = unpopulate(val, "Properties", &p.Properties) + case "addedAt": + err = unpopulateDateTimeRFC3339(val, "AddedAt", &r.AddedAt) delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &p.Tags) + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateDateTimeRFC3339(val, "LastModifiedAt", &r.LastModifiedAt) + delete(rawMsg, key) + case "origin": + err = unpopulate(val, "Origin", &r.Origin) + delete(rawMsg, key) + case "relevance": + err = unpopulate(val, "Relevance", &r.Relevance) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", r, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type PrometheusRuleGroupResourcePatchProperties. -func (p PrometheusRuleGroupResourcePatchProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type RelatedResources. +func (r RelatedResources) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "enabled", p.Enabled) + populate(objectMap, "value", r.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type PrometheusRuleGroupResourcePatchProperties. -func (p *PrometheusRuleGroupResourcePatchProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type RelatedResources. +func (r *RelatedResources) 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) + return fmt.Errorf("unmarshalling type %T: %v", r, err) } for key, val := range rawMsg { var err error switch key { - case "enabled": - err = unpopulate(val, "Enabled", &p.Enabled) + case "value": + err = unpopulate(val, "Value", &r.Value) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", r, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type PrometheusRuleResolveConfiguration. -func (p PrometheusRuleResolveConfiguration) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type RemoveAllActionGroups. +func (r RemoveAllActionGroups) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "autoResolved", p.AutoResolved) - populate(objectMap, "timeToResolve", p.TimeToResolve) + objectMap["actionType"] = ActionTypeRemoveAllActionGroups return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type PrometheusRuleResolveConfiguration. -func (p *PrometheusRuleResolveConfiguration) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type RemoveAllActionGroups. +func (r *RemoveAllActionGroups) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", r, err) } for key, val := range rawMsg { var err error switch key { - case "autoResolved": - err = unpopulate(val, "AutoResolved", &p.AutoResolved) - delete(rawMsg, key) - case "timeToResolve": - err = unpopulate(val, "TimeToResolve", &p.TimeToResolve) + case "actionType": + err = unpopulate(val, "ActionType", &r.ActionType) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", r, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type Recurrence. -func (r Recurrence) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ResourceHealthDetails. +func (r ResourceHealthDetails) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "endTime", r.EndTime) - objectMap["recurrenceType"] = r.RecurrenceType - populate(objectMap, "startTime", r.StartTime) + populate(objectMap, "category", r.Category) + objectMap["detailsType"] = DetailsTypeResourceHealth + populate(objectMap, "insight", r.Insight) + populate(objectMap, "resourceIds", r.ResourceIDs) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type Recurrence. -func (r *Recurrence) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceHealthDetails. +func (r *ResourceHealthDetails) 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) @@ -1731,14 +3869,17 @@ func (r *Recurrence) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "endTime": - err = unpopulate(val, "EndTime", &r.EndTime) + case "category": + err = unpopulate(val, "Category", &r.Category) delete(rawMsg, key) - case "recurrenceType": - err = unpopulate(val, "RecurrenceType", &r.RecurrenceType) + case "detailsType": + err = unpopulate(val, "DetailsType", &r.DetailsType) delete(rawMsg, key) - case "startTime": - err = unpopulate(val, "StartTime", &r.StartTime) + case "insight": + err = unpopulate(val, "Insight", &r.Insight) + delete(rawMsg, key) + case "resourceIds": + err = unpopulate(val, "ResourceIDs", &r.ResourceIDs) delete(rawMsg, key) } if err != nil { @@ -1748,15 +3889,18 @@ func (r *Recurrence) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type RemoveAllActionGroups. -func (r RemoveAllActionGroups) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ResourceHealthInsight. +func (r ResourceHealthInsight) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - objectMap["actionType"] = ActionTypeRemoveAllActionGroups + populate(objectMap, "availabilityState", r.AvailabilityState) + populateDateTimeRFC3339(objectMap, "occurredTime", r.OccurredTime) + populate(objectMap, "summary", r.Summary) + populate(objectMap, "title", r.Title) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type RemoveAllActionGroups. -func (r *RemoveAllActionGroups) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceHealthInsight. +func (r *ResourceHealthInsight) 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) @@ -1764,8 +3908,17 @@ func (r *RemoveAllActionGroups) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "actionType": - err = unpopulate(val, "ActionType", &r.ActionType) + case "availabilityState": + err = unpopulate(val, "AvailabilityState", &r.AvailabilityState) + delete(rawMsg, key) + case "occurredTime": + err = unpopulateDateTimeRFC3339(val, "OccurredTime", &r.OccurredTime) + delete(rawMsg, key) + case "summary": + err = unpopulate(val, "Summary", &r.Summary) + delete(rawMsg, key) + case "title": + err = unpopulate(val, "Title", &r.Title) delete(rawMsg, key) } if err != nil { @@ -1818,6 +3971,72 @@ func (r *RuleArmTemplate) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type RulePreviewResult. +func (r RulePreviewResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "dimensionCombinations", r.DimensionCombinations) + populate(objectMap, "evaluations", r.Evaluations) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RulePreviewResult. +func (r *RulePreviewResult) 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 "dimensionCombinations": + err = unpopulate(val, "DimensionCombinations", &r.DimensionCombinations) + delete(rawMsg, key) + case "evaluations": + err = unpopulate(val, "Evaluations", &r.Evaluations) + 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 RunParameters. +func (r RunParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "alerts", r.Alerts) + populateDateTimeRFC3339(objectMap, "impactTime", r.ImpactTime) + populate(objectMap, "resources", r.Resources) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RunParameters. +func (r *RunParameters) 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 "alerts": + err = unpopulate(val, "Alerts", &r.Alerts) + delete(rawMsg, key) + case "impactTime": + err = unpopulateDateTimeRFC3339(val, "ImpactTime", &r.ImpactTime) + delete(rawMsg, key) + case "resources": + err = unpopulate(val, "Resources", &r.Resources) + 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) @@ -2162,6 +4381,76 @@ func (s *SmartGroupsList) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type StartInvestigationParameters. +func (s StartInvestigationParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "impactTime", s.ImpactTime) + populate(objectMap, "investigationScopes", s.InvestigationScopes) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StartInvestigationParameters. +func (s *StartInvestigationParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "impactTime": + err = unpopulateDateTimeRFC3339(val, "ImpactTime", &s.ImpactTime) + delete(rawMsg, key) + case "investigationScopes": + err = unpopulate(val, "InvestigationScopes", &s.InvestigationScopes) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Summary. +func (s Summary) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "possibleExplanation", s.PossibleExplanation) + populate(objectMap, "title", s.Title) + populate(objectMap, "whatCanBeDoneNext", s.WhatCanBeDoneNext) + populate(objectMap, "whatHappened", s.WhatHappened) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Summary. +func (s *Summary) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "possibleExplanation": + err = unpopulate(val, "PossibleExplanation", &s.PossibleExplanation) + delete(rawMsg, key) + case "title": + err = unpopulate(val, "Title", &s.Title) + delete(rawMsg, key) + case "whatCanBeDoneNext": + err = unpopulate(val, "WhatCanBeDoneNext", &s.WhatCanBeDoneNext) + delete(rawMsg, key) + case "whatHappened": + err = unpopulate(val, "WhatHappened", &s.WhatHappened) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type SystemData. func (s SystemData) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -2209,20 +4498,18 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type TenantActivityLogAlertResource. -func (t TenantActivityLogAlertResource) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type TracePatternAnomaly. +func (t TracePatternAnomaly) 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, "properties", t.Properties) - populate(objectMap, "tags", t.Tags) - populate(objectMap, "type", t.Type) + populate(objectMap, "count", t.Count) + populate(objectMap, "generatedMessage", t.GeneratedMessage) + populate(objectMap, "pattern", t.Pattern) + populate(objectMap, "sampleEvent", t.SampleEvent) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type TenantActivityLogAlertResource. -func (t *TenantActivityLogAlertResource) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type TracePatternAnomaly. +func (t *TracePatternAnomaly) 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) @@ -2230,23 +4517,17 @@ func (t *TenantActivityLogAlertResource) UnmarshalJSON(data []byte) error { 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) + case "count": + err = unpopulate(val, "Count", &t.Count) delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &t.Properties) + case "generatedMessage": + err = unpopulate(val, "GeneratedMessage", &t.GeneratedMessage) delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &t.Tags) + case "pattern": + err = unpopulate(val, "Pattern", &t.Pattern) delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &t.Type) + case "sampleEvent": + err = unpopulate(val, "SampleEvent", &t.SampleEvent) delete(rawMsg, key) } if err != nil { @@ -2256,16 +4537,17 @@ func (t *TenantActivityLogAlertResource) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type TenantAlertRuleList. -func (t TenantAlertRuleList) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type TransactionEdge. +func (t TransactionEdge) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", t.NextLink) - populate(objectMap, "value", t.Value) + populate(objectMap, "end", t.End) + populate(objectMap, "metadata", t.Metadata) + populate(objectMap, "start", t.Start) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type TenantAlertRuleList. -func (t *TenantAlertRuleList) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type TransactionEdge. +func (t *TransactionEdge) 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) @@ -2273,11 +4555,14 @@ func (t *TenantAlertRuleList) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &t.NextLink) + case "end": + err = unpopulate(val, "End", &t.End) delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &t.Value) + case "metadata": + err = unpopulate(val, "Metadata", &t.Metadata) + delete(rawMsg, key) + case "start": + err = unpopulate(val, "Start", &t.Start) delete(rawMsg, key) } if err != nil { @@ -2287,16 +4572,16 @@ func (t *TenantAlertRuleList) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type TenantAlertRulePatchObject. -func (t TenantAlertRulePatchObject) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type TransactionNode. +func (t TransactionNode) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "properties", t.Properties) - populate(objectMap, "tags", t.Tags) + populate(objectMap, "id", t.ID) + populate(objectMap, "metadata", t.Metadata) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type TenantAlertRulePatchObject. -func (t *TenantAlertRulePatchObject) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type TransactionNode. +func (t *TransactionNode) 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) @@ -2304,11 +4589,11 @@ func (t *TenantAlertRulePatchObject) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "properties": - err = unpopulate(val, "Properties", &t.Properties) + case "id": + err = unpopulate(val, "ID", &t.ID) delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &t.Tags) + case "metadata": + err = unpopulate(val, "Metadata", &t.Metadata) delete(rawMsg, key) } if err != nil { @@ -2318,15 +4603,19 @@ func (t *TenantAlertRulePatchObject) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type TenantAlertRulePatchProperties. -func (t TenantAlertRulePatchProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type TransactionPatternAnomaly. +func (t TransactionPatternAnomaly) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "enabled", t.Enabled) + populate(objectMap, "edges", t.Edges) + populate(objectMap, "generatedMessage", t.GeneratedMessage) + populate(objectMap, "name", t.Name) + populate(objectMap, "nodes", t.Nodes) + populate(objectMap, "targetNode", t.TargetNode) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type TenantAlertRulePatchProperties. -func (t *TenantAlertRulePatchProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type TransactionPatternAnomaly. +func (t *TransactionPatternAnomaly) 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) @@ -2334,8 +4623,20 @@ func (t *TenantAlertRulePatchProperties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "enabled": - err = unpopulate(val, "Enabled", &t.Enabled) + case "edges": + err = unpopulate(val, "Edges", &t.Edges) + delete(rawMsg, key) + case "generatedMessage": + err = unpopulate(val, "GeneratedMessage", &t.GeneratedMessage) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &t.Name) + delete(rawMsg, key) + case "nodes": + err = unpopulate(val, "Nodes", &t.Nodes) + delete(rawMsg, key) + case "targetNode": + err = unpopulate(val, "TargetNode", &t.TargetNode) delete(rawMsg, key) } if err != nil { diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/operations_client.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/operations_client.go index 53d024a49a39..d226e975d6b4 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/operations_client.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/operations_client.go @@ -1,6 +1,3 @@ -//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. @@ -39,7 +36,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 2024-01-01-preview // - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ @@ -65,14 +62,14 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption } // listCreateRequest creates the List request. -func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { +func (client *OperationsClient) listCreateRequest(ctx context.Context, _ *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.AlertsManagement/operations" 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", "2019-05-05-preview") + reqQP.Set("api-version", "2024-01-01-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 5c653a2bbaa3..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/6d2438481021a94793b07b226df06d5f3c61d51d/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 95c0f243d9b5..539feced8402 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/options.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/options.go @@ -1,6 +1,3 @@ -//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. @@ -124,6 +121,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 @@ -167,11 +169,77 @@ 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 } +// ClientPreviewAlertRuleOptions contains the optional parameters for the Client.PreviewAlertRule method. +type ClientPreviewAlertRuleOptions struct { + // placeholder for future optional parameters +} + +// IssueClientAddOrUpdateAlertsOptions contains the optional parameters for the IssueClient.AddOrUpdateAlerts method. +type IssueClientAddOrUpdateAlertsOptions struct { + // placeholder for future optional parameters +} + +// IssueClientAddOrUpdateResourcesOptions contains the optional parameters for the IssueClient.AddOrUpdateResources method. +type IssueClientAddOrUpdateResourcesOptions struct { + // placeholder for future optional parameters +} + +// IssueClientCreateOptions contains the optional parameters for the IssueClient.Create method. +type IssueClientCreateOptions struct { + // placeholder for future optional parameters +} + +// IssueClientDeleteOptions contains the optional parameters for the IssueClient.Delete method. +type IssueClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// IssueClientFetchInvestigationResultOptions contains the optional parameters for the IssueClient.FetchInvestigationResult +// method. +type IssueClientFetchInvestigationResultOptions struct { + // placeholder for future optional parameters +} + +// IssueClientGetOptions contains the optional parameters for the IssueClient.Get method. +type IssueClientGetOptions struct { + // placeholder for future optional parameters +} + +// IssueClientListAlertsOptions contains the optional parameters for the IssueClient.NewListAlertsPager method. +type IssueClientListAlertsOptions struct { + // placeholder for future optional parameters +} + +// IssueClientListOptions contains the optional parameters for the IssueClient.NewListPager method. +type IssueClientListOptions struct { + // placeholder for future optional parameters +} + +// IssueClientListResourcesOptions contains the optional parameters for the IssueClient.NewListResourcesPager method. +type IssueClientListResourcesOptions struct { + // placeholder for future optional parameters +} + +// IssueClientStartInvestigationOptions contains the optional parameters for the IssueClient.StartInvestigation method. +type IssueClientStartInvestigationOptions struct { + // placeholder for future optional parameters +} + +// IssueClientUpdateOptions contains the optional parameters for the IssueClient.Update method. +type IssueClientUpdateOptions struct { + // placeholder for future optional parameters +} + // OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. type OperationsClientListOptions struct { // placeholder for future optional parameters @@ -261,38 +329,3 @@ type SmartGroupsClientGetByIDOptions struct { type SmartGroupsClientGetHistoryOptions struct { // placeholder for future optional parameters } - -// TenantActivityLogAlertsClientCreateOrUpdateOptions contains the optional parameters for the TenantActivityLogAlertsClient.CreateOrUpdate -// method. -type TenantActivityLogAlertsClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// TenantActivityLogAlertsClientDeleteOptions contains the optional parameters for the TenantActivityLogAlertsClient.Delete -// method. -type TenantActivityLogAlertsClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// TenantActivityLogAlertsClientGetOptions contains the optional parameters for the TenantActivityLogAlertsClient.Get method. -type TenantActivityLogAlertsClientGetOptions struct { - // placeholder for future optional parameters -} - -// TenantActivityLogAlertsClientListByManagementGroupOptions contains the optional parameters for the TenantActivityLogAlertsClient.NewListByManagementGroupPager -// method. -type TenantActivityLogAlertsClientListByManagementGroupOptions struct { - // placeholder for future optional parameters -} - -// TenantActivityLogAlertsClientListByTenantOptions contains the optional parameters for the TenantActivityLogAlertsClient.NewListByTenantPager -// method. -type TenantActivityLogAlertsClientListByTenantOptions struct { - // placeholder for future optional parameters -} - -// TenantActivityLogAlertsClientUpdateOptions contains the optional parameters for the TenantActivityLogAlertsClient.Update -// method. -type TenantActivityLogAlertsClientUpdateOptions 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 9d269dab22e7..e3b1a519054b 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/polymorphic_helpers.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/polymorphic_helpers.go @@ -1,6 +1,3 @@ -//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. @@ -52,6 +49,50 @@ func unmarshalActionClassificationArray(rawMsg json.RawMessage) ([]ActionClassif return fArray, nil } +func unmarshalAlertEnrichmentItemClassification(rawMsg json.RawMessage) (AlertEnrichmentItemClassification, error) { + if rawMsg == nil || string(rawMsg) == "null" { + 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 || string(rawMsg) == "null" { + 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 || string(rawMsg) == "null" { return nil, nil @@ -73,6 +114,37 @@ func unmarshalAlertsMetaDataPropertiesClassification(rawMsg json.RawMessage) (Al return b, nil } +func unmarshalDetailsBaseClassification(rawMsg json.RawMessage) (DetailsBaseClassification, error) { + if rawMsg == nil || string(rawMsg) == "null" { + return nil, nil + } + var m map[string]any + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b DetailsBaseClassification + switch m["detailsType"] { + case string(DetailsTypeAbnormalEvent): + b = &AbnormalEventDetails{} + case string(DetailsTypeAzureMetric): + b = &AzureMetricDetails{} + case string(DetailsTypeDiagnostics): + b = &DiagnosticsSolutionDetails{} + case string(DetailsTypeInvestigation): + b = &InvestigationDetails{} + case string(DetailsTypeRelatedAlert): + b = &RelatedAlertDetails{} + case string(DetailsTypeResourceHealth): + b = &ResourceHealthDetails{} + default: + b = &DetailsBase{} + } + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil +} + func unmarshalRecurrenceClassification(rawMsg json.RawMessage) (RecurrenceClassification, error) { if rawMsg == nil || string(rawMsg) == "null" { return nil, nil diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/prometheusrulegroups_client.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/prometheusrulegroups_client.go index 20ab0125bf09..ac4fa98e1928 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/prometheusrulegroups_client.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/prometheusrulegroups_client.go @@ -1,6 +1,3 @@ -//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. @@ -46,7 +43,7 @@ func NewPrometheusRuleGroupsClient(subscriptionID string, credential azcore.Toke // CreateOrUpdate - Create or update a Prometheus rule group definition. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-07-22-preview +// 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. @@ -75,7 +72,7 @@ func (client *PrometheusRuleGroupsClient) CreateOrUpdate(ctx context.Context, re } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *PrometheusRuleGroupsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, ruleGroupName string, parameters PrometheusRuleGroupResource, options *PrometheusRuleGroupsClientCreateOrUpdateOptions) (*policy.Request, error) { +func (client *PrometheusRuleGroupsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, ruleGroupName string, parameters PrometheusRuleGroupResource, _ *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") @@ -94,7 +91,7 @@ func (client *PrometheusRuleGroupsClient) createOrUpdateCreateRequest(ctx contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-07-22-preview") + 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 { @@ -115,7 +112,7 @@ func (client *PrometheusRuleGroupsClient) createOrUpdateHandleResponse(resp *htt // Delete - Delete a Prometheus rule group definition. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-07-22-preview +// 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 @@ -142,7 +139,7 @@ func (client *PrometheusRuleGroupsClient) Delete(ctx context.Context, resourceGr } // deleteCreateRequest creates the Delete request. -func (client *PrometheusRuleGroupsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, ruleGroupName string, options *PrometheusRuleGroupsClientDeleteOptions) (*policy.Request, error) { +func (client *PrometheusRuleGroupsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, ruleGroupName string, _ *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") @@ -161,7 +158,7 @@ func (client *PrometheusRuleGroupsClient) deleteCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-07-22-preview") + reqQP.Set("api-version", "2023-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -170,7 +167,7 @@ func (client *PrometheusRuleGroupsClient) deleteCreateRequest(ctx context.Contex // Get - Retrieve a Prometheus rule group definition. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-07-22-preview +// 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 @@ -198,7 +195,7 @@ func (client *PrometheusRuleGroupsClient) Get(ctx context.Context, resourceGroup } // getCreateRequest creates the Get request. -func (client *PrometheusRuleGroupsClient) getCreateRequest(ctx context.Context, resourceGroupName string, ruleGroupName string, options *PrometheusRuleGroupsClientGetOptions) (*policy.Request, error) { +func (client *PrometheusRuleGroupsClient) getCreateRequest(ctx context.Context, resourceGroupName string, ruleGroupName string, _ *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") @@ -217,7 +214,7 @@ func (client *PrometheusRuleGroupsClient) getCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-07-22-preview") + reqQP.Set("api-version", "2023-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -234,7 +231,7 @@ func (client *PrometheusRuleGroupsClient) getHandleResponse(resp *http.Response) // NewListByResourceGroupPager - Retrieve Prometheus rule group definitions in a resource group. // -// Generated from API version 2021-07-22-preview +// 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. @@ -263,7 +260,7 @@ func (client *PrometheusRuleGroupsClient) NewListByResourceGroupPager(resourceGr } // listByResourceGroupCreateRequest creates the ListByResourceGroup request. -func (client *PrometheusRuleGroupsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *PrometheusRuleGroupsClientListByResourceGroupOptions) (*policy.Request, error) { +func (client *PrometheusRuleGroupsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, _ *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") @@ -278,7 +275,7 @@ func (client *PrometheusRuleGroupsClient) listByResourceGroupCreateRequest(ctx c return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-07-22-preview") + reqQP.Set("api-version", "2023-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -293,9 +290,9 @@ func (client *PrometheusRuleGroupsClient) listByResourceGroupHandleResponse(resp return result, nil } -// NewListBySubscriptionPager - Retrieve Prometheus rule group definitions in a subscription. +// NewListBySubscriptionPager - Retrieve Prometheus all rule group definitions in a subscription. // -// Generated from API version 2021-07-22-preview +// 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] { @@ -323,7 +320,7 @@ func (client *PrometheusRuleGroupsClient) NewListBySubscriptionPager(options *Pr } // listBySubscriptionCreateRequest creates the ListBySubscription request. -func (client *PrometheusRuleGroupsClient) listBySubscriptionCreateRequest(ctx context.Context, options *PrometheusRuleGroupsClientListBySubscriptionOptions) (*policy.Request, error) { +func (client *PrometheusRuleGroupsClient) listBySubscriptionCreateRequest(ctx context.Context, _ *PrometheusRuleGroupsClientListBySubscriptionOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/prometheusRuleGroups" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -334,7 +331,7 @@ func (client *PrometheusRuleGroupsClient) listBySubscriptionCreateRequest(ctx co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-07-22-preview") + reqQP.Set("api-version", "2023-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -352,13 +349,13 @@ func (client *PrometheusRuleGroupsClient) listBySubscriptionHandleResponse(resp // Update - Update an Prometheus rule group definition. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-07-22-preview +// 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 PrometheusRuleGroupResourcePatch, options *PrometheusRuleGroupsClientUpdateOptions) (PrometheusRuleGroupsClientUpdateResponse, error) { +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) @@ -381,7 +378,7 @@ func (client *PrometheusRuleGroupsClient) Update(ctx context.Context, resourceGr } // updateCreateRequest creates the Update request. -func (client *PrometheusRuleGroupsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, ruleGroupName string, parameters PrometheusRuleGroupResourcePatch, options *PrometheusRuleGroupsClientUpdateOptions) (*policy.Request, error) { +func (client *PrometheusRuleGroupsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, ruleGroupName string, parameters PrometheusRuleGroupResourcePatchParameters, _ *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") @@ -400,7 +397,7 @@ func (client *PrometheusRuleGroupsClient) updateCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-07-22-preview") + 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 { diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/prometheusrulegroups_client_example_test.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/prometheusrulegroups_client_example_test.go deleted file mode 100644 index d42aa9d6742d..000000000000 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/prometheusrulegroups_client_example_test.go +++ /dev/null @@ -1,473 +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/6d2438481021a94793b07b226df06d5f3c61d51d/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2021-07-22-preview/examples/listSubscriptionPrometheusRuleGroups.json -func ExamplePrometheusRuleGroupsClient_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.NewPrometheusRuleGroupsClient().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.PrometheusRuleGroupResourceCollection = armalertsmanagement.PrometheusRuleGroupResourceCollection{ - // Value: []*armalertsmanagement.PrometheusRuleGroupResource{ - // { - // Type: to.Ptr("Microsoft.AlertsManagement/prometheusRuleGroups"), - // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/promResourceGroup/providers/Microsoft.AlertsManagement/prometheusRuleGroups/myPrometheusRuleGroup"), - // 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), - // }, - // Location: to.Ptr("East US"), - // Properties: &armalertsmanagement.PrometheusRuleGroupProperties{ - // Description: to.Ptr("This is the description of the first rule group"), - // Rules: []*armalertsmanagement.PrometheusRule{ - // { - // Expression: to.Ptr("histogram_quantile(0.99, sum(rate(jobs_duration_seconds_bucket{service=\"billing-processing\"}[5m])) by (job_type))"), - // Record: to.Ptr("job_type:billing_jobs_duration_seconds:99p5m"), - // }, - // { - // Actions: []*armalertsmanagement.PrometheusRuleGroupAction{ - // { - // ActionGroupID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/promResourceGroup/providers/microsoft.insights/actiongroups/group2"), - // ActionProperties: map[string]*string{ - // "key11": to.Ptr("value11"), - // "key12": to.Ptr("value12"), - // }, - // }}, - // Alert: to.Ptr("Billing_Processing_Very_Slow"), - // Expression: to.Ptr("job_type:billing_jobs_duration_seconds:99p5m > 30"), - // For: to.Ptr("5m"), - // Labels: map[string]*string{ - // "team": to.Ptr("prod"), - // }, - // ResolveConfiguration: &armalertsmanagement.PrometheusRuleResolveConfiguration{ - // AutoResolved: to.Ptr(true), - // TimeToResolve: to.Ptr("10m"), - // }, - // Severity: to.Ptr[int32](2), - // }}, - // Scopes: []*string{ - // to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/promResourceGroup/providers/microsoft.monitor/accounts/monitoringAcount/myMonitoringAccount")}, - // }, - // }, - // { - // Type: to.Ptr("Microsoft.AlertsManagement/prometheusRuleGroups"), - // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/promResourceGroup/providers/Microsoft.AlertsManagement/prometheusRuleGroups/myPrometheusRuleGroup2"), - // SystemData: &armalertsmanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-12T22:05:13.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:13.000Z"); return t}()), - // LastModifiedBy: to.Ptr("xyz@microsoft.com"), - // LastModifiedByType: to.Ptr(armalertsmanagement.CreatedByTypeUser), - // }, - // Location: to.Ptr("East US"), - // Properties: &armalertsmanagement.PrometheusRuleGroupProperties{ - // Description: to.Ptr("This is the description of the first rule group"), - // Rules: []*armalertsmanagement.PrometheusRule{ - // { - // Expression: to.Ptr("histogram_quantile(0.99, sum(rate(jobs_duration_seconds_bucket{service=\"billing-processing\"}[5m])) by (job_type))"), - // Record: to.Ptr("job_type:billing_jobs_duration_seconds:99p5m"), - // }, - // { - // Actions: []*armalertsmanagement.PrometheusRuleGroupAction{ - // { - // ActionGroupID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/promResourceGroup/providers/microsoft.insights/actiongroups/group2"), - // ActionProperties: map[string]*string{ - // "key11": to.Ptr("value11"), - // "key12": to.Ptr("value12"), - // }, - // }}, - // Alert: to.Ptr("Billing_Processing_Very_Slow"), - // Expression: to.Ptr("job_type:billing_jobs_duration_seconds:99p5m > 30"), - // For: to.Ptr("5m"), - // Labels: map[string]*string{ - // "team": to.Ptr("prod"), - // }, - // ResolveConfiguration: &armalertsmanagement.PrometheusRuleResolveConfiguration{ - // AutoResolved: to.Ptr(true), - // TimeToResolve: to.Ptr("10m"), - // }, - // Severity: to.Ptr[int32](2), - // }}, - // Scopes: []*string{ - // to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/promResourceGroup/providers/microsoft.monitor/accounts/monitoringAcount/myMonitoringAccount")}, - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/6d2438481021a94793b07b226df06d5f3c61d51d/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2021-07-22-preview/examples/listPrometheusRuleGroups.json -func ExamplePrometheusRuleGroupsClient_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.NewPrometheusRuleGroupsClient().NewListByResourceGroupPager("promResourceGroup", 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.PrometheusRuleGroupResourceCollection = armalertsmanagement.PrometheusRuleGroupResourceCollection{ - // Value: []*armalertsmanagement.PrometheusRuleGroupResource{ - // { - // Type: to.Ptr("Microsoft.AlertsManagement/prometheusRuleGroups"), - // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/promResourceGroup/providers/Microsoft.AlertsManagement/prometheusRuleGroups/myPrometheusRuleGroup"), - // 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), - // }, - // Location: to.Ptr("East US"), - // Properties: &armalertsmanagement.PrometheusRuleGroupProperties{ - // Description: to.Ptr("This is the description of the first rule group"), - // Rules: []*armalertsmanagement.PrometheusRule{ - // { - // Expression: to.Ptr("histogram_quantile(0.99, sum(rate(jobs_duration_seconds_bucket{service=\"billing-processing\"}[5m])) by (job_type))"), - // Record: to.Ptr("job_type:billing_jobs_duration_seconds:99p5m"), - // }, - // { - // Actions: []*armalertsmanagement.PrometheusRuleGroupAction{ - // { - // ActionGroupID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"), - // ActionProperties: map[string]*string{ - // "key11": to.Ptr("value11"), - // "key12": to.Ptr("value12"), - // }, - // }}, - // Alert: to.Ptr("Billing_Processing_Very_Slow"), - // Expression: to.Ptr("job_type:billing_jobs_duration_seconds:99p5m > 30"), - // For: to.Ptr("5m"), - // Labels: map[string]*string{ - // "team": to.Ptr("prod"), - // }, - // ResolveConfiguration: &armalertsmanagement.PrometheusRuleResolveConfiguration{ - // AutoResolved: to.Ptr(true), - // TimeToResolve: to.Ptr("10m"), - // }, - // Severity: to.Ptr[int32](2), - // }}, - // Scopes: []*string{ - // to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/promResourceGroup/providers/microsoft.monitor/accounts/myMonitoringAccount")}, - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/6d2438481021a94793b07b226df06d5f3c61d51d/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2021-07-22-preview/examples/getPrometheusRuleGroup.json -func ExamplePrometheusRuleGroupsClient_Get() { - 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.NewPrometheusRuleGroupsClient().Get(ctx, "promResourceGroup", "myPrometheusRuleGroup", 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.PrometheusRuleGroupResource = armalertsmanagement.PrometheusRuleGroupResource{ - // Type: to.Ptr("Microsoft.AlertsManagement/prometheusRuleGroups"), - // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/promResourceGroup/providers/Microsoft.AlertsManagement/prometheusRuleGroups/myPrometheusRuleGroup"), - // 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), - // }, - // Location: to.Ptr("global"), - // Properties: &armalertsmanagement.PrometheusRuleGroupProperties{ - // Description: to.Ptr("This is the description of the first rule group"), - // Rules: []*armalertsmanagement.PrometheusRule{ - // { - // Expression: to.Ptr("histogram_quantile(0.99, sum(rate(jobs_duration_seconds_bucket{service=\"billing-processing\"}[5m])) by (job_type))"), - // Record: to.Ptr("job_type:billing_jobs_duration_seconds:99p5m"), - // }, - // { - // Actions: []*armalertsmanagement.PrometheusRuleGroupAction{ - // { - // ActionGroupID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/promResourceGroup/providers/microsoft.insights/actiongroups/group2"), - // ActionProperties: map[string]*string{ - // "key11": to.Ptr("value11"), - // "key12": to.Ptr("value12"), - // }, - // }}, - // Alert: to.Ptr("Billing_Processing_Very_Slow"), - // Expression: to.Ptr("job_type:billing_jobs_duration_seconds:99p5m > 30"), - // For: to.Ptr("5m"), - // Labels: map[string]*string{ - // "team": to.Ptr("prod"), - // }, - // ResolveConfiguration: &armalertsmanagement.PrometheusRuleResolveConfiguration{ - // AutoResolved: to.Ptr(true), - // TimeToResolve: to.Ptr("10m"), - // }, - // Severity: to.Ptr[int32](2), - // }}, - // Scopes: []*string{ - // to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/promResourceGroup/providers/microsoft.monitor/accounts/myMonitoringAccount")}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/6d2438481021a94793b07b226df06d5f3c61d51d/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2021-07-22-preview/examples/createOrUpdatePrometheusRuleGroup.json -func ExamplePrometheusRuleGroupsClient_CreateOrUpdate() { - 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.NewPrometheusRuleGroupsClient().CreateOrUpdate(ctx, "promResourceGroup", "myPrometheusRuleGroup", armalertsmanagement.PrometheusRuleGroupResource{ - Location: to.Ptr("East US"), - Properties: &armalertsmanagement.PrometheusRuleGroupProperties{ - Description: to.Ptr("This is the description of the first rule group"), - Rules: []*armalertsmanagement.PrometheusRule{ - { - Expression: to.Ptr("histogram_quantile(0.99, sum(rate(jobs_duration_seconds_bucket{service=\"billing-processing\"}[5m])) by (job_type))"), - Labels: map[string]*string{ - "team": to.Ptr("prod"), - }, - Record: to.Ptr("job_type:billing_jobs_duration_seconds:99p5m"), - }, - { - Actions: []*armalertsmanagement.PrometheusRuleGroupAction{ - { - ActionGroupID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/promResourceGroup/providers/microsoft.insights/actiongroups/group2"), - ActionProperties: map[string]*string{ - "key11": to.Ptr("value11"), - "key12": to.Ptr("value12"), - }, - }}, - Alert: to.Ptr("Billing_Processing_Very_Slow"), - Annotations: map[string]*string{ - "annotationName1": to.Ptr("annotationValue1"), - }, - Expression: to.Ptr("job_type:billing_jobs_duration_seconds:99p5m > 30"), - For: to.Ptr("PT5M"), - Labels: map[string]*string{ - "team": to.Ptr("prod"), - }, - ResolveConfiguration: &armalertsmanagement.PrometheusRuleResolveConfiguration{ - AutoResolved: to.Ptr(true), - TimeToResolve: to.Ptr("PT10M"), - }, - Severity: to.Ptr[int32](2), - }}, - Scopes: []*string{ - to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/promResourceGroup/providers/microsoft.monitor/accounts/myMonitoringAccount")}, - }, - }, 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.PrometheusRuleGroupResource = armalertsmanagement.PrometheusRuleGroupResource{ - // Type: to.Ptr("Microsoft.AlertsManagement/prometheusRuleGroups"), - // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/promResourceGroup/providers/Microsoft.AlertsManagement/prometheusRuleGroups/myPrometheusRuleGroup"), - // 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), - // }, - // Location: to.Ptr("East US"), - // Properties: &armalertsmanagement.PrometheusRuleGroupProperties{ - // Description: to.Ptr("This is the description of the first rule group"), - // Interval: to.Ptr("PT5M"), - // Rules: []*armalertsmanagement.PrometheusRule{ - // { - // Expression: to.Ptr("histogram_quantile(0.99, sum(rate(jobs_duration_seconds_bucket{service=\"billing-processing\"}[5m])) by (job_type))"), - // Labels: map[string]*string{ - // "team": to.Ptr("prod"), - // }, - // Record: to.Ptr("job_type:billing_jobs_duration_seconds:99p5m"), - // }, - // { - // Actions: []*armalertsmanagement.PrometheusRuleGroupAction{ - // { - // ActionGroupID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/promResourceGroup/providers/microsoft.insights/actiongroups/group2"), - // ActionProperties: map[string]*string{ - // "key11": to.Ptr("value11"), - // "key12": to.Ptr("value12"), - // }, - // }}, - // Alert: to.Ptr("Billing_Processing_Very_Slow"), - // Annotations: map[string]*string{ - // "annotationName1": to.Ptr("annotationValue1"), - // }, - // Expression: to.Ptr("job_type:billing_jobs_duration_seconds:99p5m > 30"), - // For: to.Ptr("PT5M"), - // Labels: map[string]*string{ - // "team": to.Ptr("prod"), - // }, - // ResolveConfiguration: &armalertsmanagement.PrometheusRuleResolveConfiguration{ - // AutoResolved: to.Ptr(true), - // TimeToResolve: to.Ptr("PT10M"), - // }, - // Severity: to.Ptr[int32](2), - // }}, - // Scopes: []*string{ - // to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/promResourceGroup/providers/microsoft.monitor/accounts/myMonitoringAccount")}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/6d2438481021a94793b07b226df06d5f3c61d51d/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2021-07-22-preview/examples/patchPrometheusRuleGroup.json -func ExamplePrometheusRuleGroupsClient_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.NewPrometheusRuleGroupsClient().Update(ctx, "promResourceGroup", "myPrometheusRuleGroup", armalertsmanagement.PrometheusRuleGroupResourcePatch{ - Properties: &armalertsmanagement.PrometheusRuleGroupResourcePatchProperties{ - Enabled: to.Ptr(false), - }, - Tags: map[string]*string{ - "tag1": to.Ptr("value1"), - }, - }, 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.PrometheusRuleGroupResource = armalertsmanagement.PrometheusRuleGroupResource{ - // Type: to.Ptr("Microsoft.AlertsManagement/prometheusRuleGroups"), - // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/promResourceGroup/providers/Microsoft.AlertsManagement/prometheusRuleGroups/myPrometheusRuleGroup"), - // 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), - // }, - // Location: to.Ptr("East US"), - // Tags: map[string]*string{ - // "tag1": to.Ptr("value1"), - // }, - // Properties: &armalertsmanagement.PrometheusRuleGroupProperties{ - // Description: to.Ptr("This is the description of the first rule group"), - // Enabled: to.Ptr(false), - // Rules: []*armalertsmanagement.PrometheusRule{ - // { - // Expression: to.Ptr("histogram_quantile(0.99, sum(rate(jobs_duration_seconds_bucket{service=\"billing-processing\"}[5m])) by (job_type))"), - // Record: to.Ptr("job_type:billing_jobs_duration_seconds:99p5m"), - // }, - // { - // Actions: []*armalertsmanagement.PrometheusRuleGroupAction{ - // { - // ActionGroupID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/promResourceGroup/providers/microsoft.insights/actiongroups/group2"), - // ActionProperties: map[string]*string{ - // "key11": to.Ptr("value11"), - // "key12": to.Ptr("value12"), - // }, - // }}, - // Alert: to.Ptr("Billing_Processing_Very_Slow"), - // Expression: to.Ptr("job_type:billing_jobs_duration_seconds:99p5m > 30"), - // For: to.Ptr("5m"), - // Labels: map[string]*string{ - // "team": to.Ptr("prod"), - // }, - // ResolveConfiguration: &armalertsmanagement.PrometheusRuleResolveConfiguration{ - // AutoResolved: to.Ptr(true), - // TimeToResolve: to.Ptr("10m"), - // }, - // Severity: to.Ptr[int32](2), - // }}, - // Scopes: []*string{ - // to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/promResourceGroup/providers/microsoft.monitor/accounts/monitoringAcount/myMonitoringAccount")}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/6d2438481021a94793b07b226df06d5f3c61d51d/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2021-07-22-preview/examples/deletePrometheusRuleGroup.json -func ExamplePrometheusRuleGroupsClient_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.NewPrometheusRuleGroupsClient().Delete(ctx, "promResourceGroup", "myPrometheusRuleGroup", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/responses.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/responses.go index 8c562fc3658c..e16bf777a19e 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/responses.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/responses.go @@ -1,6 +1,3 @@ -//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. @@ -89,6 +86,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 @@ -101,12 +104,88 @@ 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. AlertsMetaData } +// ClientPreviewAlertRuleResponse contains the response from method Client.PreviewAlertRule. +type ClientPreviewAlertRuleResponse struct { + PreviewAlertRuleResponse +} + +// IssueClientAddOrUpdateAlertsResponse contains the response from method IssueClient.AddOrUpdateAlerts. +type IssueClientAddOrUpdateAlertsResponse struct { + // A list of related alerts + RelatedAlerts +} + +// IssueClientAddOrUpdateResourcesResponse contains the response from method IssueClient.AddOrUpdateResources. +type IssueClientAddOrUpdateResourcesResponse struct { + // A list of related resources + RelatedResources +} + +// IssueClientCreateResponse contains the response from method IssueClient.Create. +type IssueClientCreateResponse struct { + // The Issue resource + IssueResource +} + +// IssueClientDeleteResponse contains the response from method IssueClient.Delete. +type IssueClientDeleteResponse struct { + // placeholder for future response values +} + +// IssueClientFetchInvestigationResultResponse contains the response from method IssueClient.FetchInvestigationResult. +type IssueClientFetchInvestigationResultResponse struct { + // Details about the investigation result + InvestigationResult +} + +// IssueClientGetResponse contains the response from method IssueClient.Get. +type IssueClientGetResponse struct { + // The Issue resource + IssueResource +} + +// IssueClientListAlertsResponse contains the response from method IssueClient.NewListAlertsPager. +type IssueClientListAlertsResponse struct { + // Paged collection of RelatedAlert items + PagedRelatedAlert +} + +// IssueClientListResourcesResponse contains the response from method IssueClient.NewListResourcesPager. +type IssueClientListResourcesResponse struct { + // Paged collection of RelatedResource items + PagedRelatedResource +} + +// IssueClientListResponse contains the response from method IssueClient.NewListPager. +type IssueClientListResponse struct { + // The response of a IssueResource list operation. + IssueResourceListResult +} + +// IssueClientStartInvestigationResponse contains the response from method IssueClient.StartInvestigation. +type IssueClientStartInvestigationResponse struct { + // Properties of the current investigation + InvestigationMetadata +} + +// IssueClientUpdateResponse contains the response from method IssueClient.Update. +type IssueClientUpdateResponse struct { + // The Issue resource + IssueResource +} + // OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { // Lists the operations available in the AlertsManagement RP. @@ -177,38 +256,3 @@ type SmartGroupsClientGetHistoryResponse struct { // Alert Modification details SmartGroupModification } - -// TenantActivityLogAlertsClientCreateOrUpdateResponse contains the response from method TenantActivityLogAlertsClient.CreateOrUpdate. -type TenantActivityLogAlertsClientCreateOrUpdateResponse struct { - // A Tenant Activity Log Alert rule resource. - TenantActivityLogAlertResource -} - -// TenantActivityLogAlertsClientDeleteResponse contains the response from method TenantActivityLogAlertsClient.Delete. -type TenantActivityLogAlertsClientDeleteResponse struct { - // placeholder for future response values -} - -// TenantActivityLogAlertsClientGetResponse contains the response from method TenantActivityLogAlertsClient.Get. -type TenantActivityLogAlertsClientGetResponse struct { - // A Tenant Activity Log Alert rule resource. - TenantActivityLogAlertResource -} - -// TenantActivityLogAlertsClientListByManagementGroupResponse contains the response from method TenantActivityLogAlertsClient.NewListByManagementGroupPager. -type TenantActivityLogAlertsClientListByManagementGroupResponse struct { - // A list of Tenant Activity Log Alert rules. - TenantAlertRuleList -} - -// TenantActivityLogAlertsClientListByTenantResponse contains the response from method TenantActivityLogAlertsClient.NewListByTenantPager. -type TenantActivityLogAlertsClientListByTenantResponse struct { - // A list of Tenant Activity Log Alert rules. - TenantAlertRuleList -} - -// TenantActivityLogAlertsClientUpdateResponse contains the response from method TenantActivityLogAlertsClient.Update. -type TenantActivityLogAlertsClientUpdateResponse struct { - // A Tenant Activity Log Alert rule resource. - TenantActivityLogAlertResource -} diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/smartgroups_client.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/smartgroups_client.go index 4abbc62e1e68..ea9b8321b47d 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/smartgroups_client.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/smartgroups_client.go @@ -1,6 +1,3 @@ -//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. @@ -74,7 +71,7 @@ func (client *SmartGroupsClient) ChangeState(ctx context.Context, smartGroupID s } // changeStateCreateRequest creates the ChangeState request. -func (client *SmartGroupsClient) changeStateCreateRequest(ctx context.Context, smartGroupID string, newState AlertState, options *SmartGroupsClientChangeStateOptions) (*policy.Request, error) { +func (client *SmartGroupsClient) changeStateCreateRequest(ctx context.Context, smartGroupID string, newState AlertState, _ *SmartGroupsClientChangeStateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/smartGroups/{smartGroupId}/changeState" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -224,7 +221,7 @@ func (client *SmartGroupsClient) GetByID(ctx context.Context, smartGroupID strin } // getByIDCreateRequest creates the GetByID request. -func (client *SmartGroupsClient) getByIDCreateRequest(ctx context.Context, smartGroupID string, options *SmartGroupsClientGetByIDOptions) (*policy.Request, error) { +func (client *SmartGroupsClient) getByIDCreateRequest(ctx context.Context, smartGroupID string, _ *SmartGroupsClientGetByIDOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/smartGroups/{smartGroupId}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -286,7 +283,7 @@ func (client *SmartGroupsClient) GetHistory(ctx context.Context, smartGroupID st } // getHistoryCreateRequest creates the GetHistory request. -func (client *SmartGroupsClient) getHistoryCreateRequest(ctx context.Context, smartGroupID string, options *SmartGroupsClientGetHistoryOptions) (*policy.Request, error) { +func (client *SmartGroupsClient) getHistoryCreateRequest(ctx context.Context, smartGroupID string, _ *SmartGroupsClientGetHistoryOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/smartGroups/{smartGroupId}/history" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") 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 a0bf5e6e5d9d..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/6d2438481021a94793b07b226df06d5f3c61d51d/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/6d2438481021a94793b07b226df06d5f3c61d51d/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/6d2438481021a94793b07b226df06d5f3c61d51d/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/6d2438481021a94793b07b226df06d5f3c61d51d/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"), - // }, - // } -} diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/tenantactivitylogalerts_client.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/tenantactivitylogalerts_client.go deleted file mode 100644 index 4cd43f6a03d3..000000000000 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/tenantactivitylogalerts_client.go +++ /dev/null @@ -1,392 +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. 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" -) - -// TenantActivityLogAlertsClient contains the methods for the TenantActivityLogAlerts group. -// Don't use this type directly, use NewTenantActivityLogAlertsClient() instead. -type TenantActivityLogAlertsClient struct { - internal *arm.Client -} - -// NewTenantActivityLogAlertsClient creates a new instance of TenantActivityLogAlertsClient with the specified values. -// - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. -func NewTenantActivityLogAlertsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*TenantActivityLogAlertsClient, error) { - cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) - if err != nil { - return nil, err - } - client := &TenantActivityLogAlertsClient{ - internal: cl, - } - return client, nil -} - -// CreateOrUpdate - Create a new Tenant Activity Log Alert rule or update an existing one. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2023-04-01-preview -// - managementGroupName - The name of the management group. The name is case insensitive. -// - alertRuleName - The name of the Tenant Activity Log Alert rule. -// - tenantActivityLogAlertRule - The Tenant Activity Log Alert rule to create or use for the update. -// - options - TenantActivityLogAlertsClientCreateOrUpdateOptions contains the optional parameters for the TenantActivityLogAlertsClient.CreateOrUpdate -// method. -func (client *TenantActivityLogAlertsClient) CreateOrUpdate(ctx context.Context, managementGroupName string, alertRuleName string, tenantActivityLogAlertRule TenantActivityLogAlertResource, options *TenantActivityLogAlertsClientCreateOrUpdateOptions) (TenantActivityLogAlertsClientCreateOrUpdateResponse, error) { - var err error - const operationName = "TenantActivityLogAlertsClient.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, managementGroupName, alertRuleName, tenantActivityLogAlertRule, options) - if err != nil { - return TenantActivityLogAlertsClientCreateOrUpdateResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return TenantActivityLogAlertsClientCreateOrUpdateResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { - err = runtime.NewResponseError(httpResp) - return TenantActivityLogAlertsClientCreateOrUpdateResponse{}, err - } - resp, err := client.createOrUpdateHandleResponse(httpResp) - return resp, err -} - -// createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *TenantActivityLogAlertsClient) createOrUpdateCreateRequest(ctx context.Context, managementGroupName string, alertRuleName string, tenantActivityLogAlertRule TenantActivityLogAlertResource, options *TenantActivityLogAlertsClientCreateOrUpdateOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.AlertsManagement/tenantActivityLogAlerts/{alertRuleName}" - if managementGroupName == "" { - return nil, errors.New("parameter managementGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{managementGroupName}", url.PathEscape(managementGroupName)) - if alertRuleName == "" { - return nil, errors.New("parameter alertRuleName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{alertRuleName}", url.PathEscape(alertRuleName)) - 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-04-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, tenantActivityLogAlertRule); err != nil { - return nil, err - } - return req, nil -} - -// createOrUpdateHandleResponse handles the CreateOrUpdate response. -func (client *TenantActivityLogAlertsClient) createOrUpdateHandleResponse(resp *http.Response) (TenantActivityLogAlertsClientCreateOrUpdateResponse, error) { - result := TenantActivityLogAlertsClientCreateOrUpdateResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.TenantActivityLogAlertResource); err != nil { - return TenantActivityLogAlertsClientCreateOrUpdateResponse{}, err - } - return result, nil -} - -// Delete - Delete a Tenant Activity Log Alert rule. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2023-04-01-preview -// - managementGroupName - The name of the management group. The name is case insensitive. -// - alertRuleName - The name of the Tenant Activity Log Alert rule. -// - options - TenantActivityLogAlertsClientDeleteOptions contains the optional parameters for the TenantActivityLogAlertsClient.Delete -// method. -func (client *TenantActivityLogAlertsClient) Delete(ctx context.Context, managementGroupName string, alertRuleName string, options *TenantActivityLogAlertsClientDeleteOptions) (TenantActivityLogAlertsClientDeleteResponse, error) { - var err error - const operationName = "TenantActivityLogAlertsClient.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, managementGroupName, alertRuleName, options) - if err != nil { - return TenantActivityLogAlertsClientDeleteResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return TenantActivityLogAlertsClientDeleteResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { - err = runtime.NewResponseError(httpResp) - return TenantActivityLogAlertsClientDeleteResponse{}, err - } - return TenantActivityLogAlertsClientDeleteResponse{}, nil -} - -// deleteCreateRequest creates the Delete request. -func (client *TenantActivityLogAlertsClient) deleteCreateRequest(ctx context.Context, managementGroupName string, alertRuleName string, options *TenantActivityLogAlertsClientDeleteOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.AlertsManagement/tenantActivityLogAlerts/{alertRuleName}" - if managementGroupName == "" { - return nil, errors.New("parameter managementGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{managementGroupName}", url.PathEscape(managementGroupName)) - if alertRuleName == "" { - return nil, errors.New("parameter alertRuleName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{alertRuleName}", url.PathEscape(alertRuleName)) - 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-04-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// Get - Get Tenant Activity Log Alert rule. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2023-04-01-preview -// - managementGroupName - The name of the management group. The name is case insensitive. -// - alertRuleName - The name of the Tenant Activity Log Alert rule. -// - options - TenantActivityLogAlertsClientGetOptions contains the optional parameters for the TenantActivityLogAlertsClient.Get -// method. -func (client *TenantActivityLogAlertsClient) Get(ctx context.Context, managementGroupName string, alertRuleName string, options *TenantActivityLogAlertsClientGetOptions) (TenantActivityLogAlertsClientGetResponse, error) { - var err error - const operationName = "TenantActivityLogAlertsClient.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, managementGroupName, alertRuleName, options) - if err != nil { - return TenantActivityLogAlertsClientGetResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return TenantActivityLogAlertsClientGetResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return TenantActivityLogAlertsClientGetResponse{}, err - } - resp, err := client.getHandleResponse(httpResp) - return resp, err -} - -// getCreateRequest creates the Get request. -func (client *TenantActivityLogAlertsClient) getCreateRequest(ctx context.Context, managementGroupName string, alertRuleName string, options *TenantActivityLogAlertsClientGetOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.AlertsManagement/tenantActivityLogAlerts/{alertRuleName}" - if managementGroupName == "" { - return nil, errors.New("parameter managementGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{managementGroupName}", url.PathEscape(managementGroupName)) - if alertRuleName == "" { - return nil, errors.New("parameter alertRuleName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{alertRuleName}", url.PathEscape(alertRuleName)) - 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-04-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *TenantActivityLogAlertsClient) getHandleResponse(resp *http.Response) (TenantActivityLogAlertsClientGetResponse, error) { - result := TenantActivityLogAlertsClientGetResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.TenantActivityLogAlertResource); err != nil { - return TenantActivityLogAlertsClientGetResponse{}, err - } - return result, nil -} - -// NewListByManagementGroupPager - Get a list of all Tenant Activity Log Alert rules in a management group. -// -// Generated from API version 2023-04-01-preview -// - managementGroupName - The name of the management group. The name is case insensitive. -// - options - TenantActivityLogAlertsClientListByManagementGroupOptions contains the optional parameters for the TenantActivityLogAlertsClient.NewListByManagementGroupPager -// method. -func (client *TenantActivityLogAlertsClient) NewListByManagementGroupPager(managementGroupName string, options *TenantActivityLogAlertsClientListByManagementGroupOptions) *runtime.Pager[TenantActivityLogAlertsClientListByManagementGroupResponse] { - return runtime.NewPager(runtime.PagingHandler[TenantActivityLogAlertsClientListByManagementGroupResponse]{ - More: func(page TenantActivityLogAlertsClientListByManagementGroupResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *TenantActivityLogAlertsClientListByManagementGroupResponse) (TenantActivityLogAlertsClientListByManagementGroupResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "TenantActivityLogAlertsClient.NewListByManagementGroupPager") - 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.listByManagementGroupCreateRequest(ctx, managementGroupName, options) - }, nil) - if err != nil { - return TenantActivityLogAlertsClientListByManagementGroupResponse{}, err - } - return client.listByManagementGroupHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listByManagementGroupCreateRequest creates the ListByManagementGroup request. -func (client *TenantActivityLogAlertsClient) listByManagementGroupCreateRequest(ctx context.Context, managementGroupName string, options *TenantActivityLogAlertsClientListByManagementGroupOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.AlertsManagement/tenantActivityLogAlerts" - if managementGroupName == "" { - return nil, errors.New("parameter managementGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{managementGroupName}", url.PathEscape(managementGroupName)) - 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-04-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listByManagementGroupHandleResponse handles the ListByManagementGroup response. -func (client *TenantActivityLogAlertsClient) listByManagementGroupHandleResponse(resp *http.Response) (TenantActivityLogAlertsClientListByManagementGroupResponse, error) { - result := TenantActivityLogAlertsClientListByManagementGroupResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.TenantAlertRuleList); err != nil { - return TenantActivityLogAlertsClientListByManagementGroupResponse{}, err - } - return result, nil -} - -// NewListByTenantPager - Get a list of all Tenant Activity Log Alert rules in the tenant. -// -// Generated from API version 2023-04-01-preview -// - options - TenantActivityLogAlertsClientListByTenantOptions contains the optional parameters for the TenantActivityLogAlertsClient.NewListByTenantPager -// method. -func (client *TenantActivityLogAlertsClient) NewListByTenantPager(options *TenantActivityLogAlertsClientListByTenantOptions) *runtime.Pager[TenantActivityLogAlertsClientListByTenantResponse] { - return runtime.NewPager(runtime.PagingHandler[TenantActivityLogAlertsClientListByTenantResponse]{ - More: func(page TenantActivityLogAlertsClientListByTenantResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *TenantActivityLogAlertsClientListByTenantResponse) (TenantActivityLogAlertsClientListByTenantResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "TenantActivityLogAlertsClient.NewListByTenantPager") - 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.listByTenantCreateRequest(ctx, options) - }, nil) - if err != nil { - return TenantActivityLogAlertsClientListByTenantResponse{}, err - } - return client.listByTenantHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listByTenantCreateRequest creates the ListByTenant request. -func (client *TenantActivityLogAlertsClient) listByTenantCreateRequest(ctx context.Context, options *TenantActivityLogAlertsClientListByTenantOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.AlertsManagement/tenantActivityLogAlerts" - 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-04-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listByTenantHandleResponse handles the ListByTenant response. -func (client *TenantActivityLogAlertsClient) listByTenantHandleResponse(resp *http.Response) (TenantActivityLogAlertsClientListByTenantResponse, error) { - result := TenantActivityLogAlertsClientListByTenantResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.TenantAlertRuleList); err != nil { - return TenantActivityLogAlertsClientListByTenantResponse{}, err - } - return result, nil -} - -// Update - Updates 'tags' and 'enabled' fields in an existing Tenant Alert rule. This method is used to update the Alert -// rule tags, and to enable or disable the Alert rule. To update other fields use -// CreateOrUpdate operation. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2023-04-01-preview -// - managementGroupName - The name of the management group. The name is case insensitive. -// - alertRuleName - The name of the Tenant Activity Log Alert rule. -// - tenantActivityLogAlertRulePatch - Parameters supplied to the operation. -// - options - TenantActivityLogAlertsClientUpdateOptions contains the optional parameters for the TenantActivityLogAlertsClient.Update -// method. -func (client *TenantActivityLogAlertsClient) Update(ctx context.Context, managementGroupName string, alertRuleName string, tenantActivityLogAlertRulePatch TenantAlertRulePatchObject, options *TenantActivityLogAlertsClientUpdateOptions) (TenantActivityLogAlertsClientUpdateResponse, error) { - var err error - const operationName = "TenantActivityLogAlertsClient.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, managementGroupName, alertRuleName, tenantActivityLogAlertRulePatch, options) - if err != nil { - return TenantActivityLogAlertsClientUpdateResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return TenantActivityLogAlertsClientUpdateResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return TenantActivityLogAlertsClientUpdateResponse{}, err - } - resp, err := client.updateHandleResponse(httpResp) - return resp, err -} - -// updateCreateRequest creates the Update request. -func (client *TenantActivityLogAlertsClient) updateCreateRequest(ctx context.Context, managementGroupName string, alertRuleName string, tenantActivityLogAlertRulePatch TenantAlertRulePatchObject, options *TenantActivityLogAlertsClientUpdateOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.AlertsManagement/tenantActivityLogAlerts/{alertRuleName}" - if managementGroupName == "" { - return nil, errors.New("parameter managementGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{managementGroupName}", url.PathEscape(managementGroupName)) - if alertRuleName == "" { - return nil, errors.New("parameter alertRuleName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{alertRuleName}", url.PathEscape(alertRuleName)) - 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-04-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, tenantActivityLogAlertRulePatch); err != nil { - return nil, err - } - return req, nil -} - -// updateHandleResponse handles the Update response. -func (client *TenantActivityLogAlertsClient) updateHandleResponse(resp *http.Response) (TenantActivityLogAlertsClientUpdateResponse, error) { - result := TenantActivityLogAlertsClientUpdateResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.TenantActivityLogAlertResource); err != nil { - return TenantActivityLogAlertsClientUpdateResponse{}, err - } - return result, nil -} diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/tenantactivitylogalerts_client_example_test.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/tenantactivitylogalerts_client_example_test.go deleted file mode 100644 index a4cc5e971e34..000000000000 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/tenantactivitylogalerts_client_example_test.go +++ /dev/null @@ -1,381 +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/6d2438481021a94793b07b226df06d5f3c61d51d/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-04-01-preview/examples/TenantActivityLogAlertRule_CreateOrUpdate.json -func ExampleTenantActivityLogAlertsClient_CreateOrUpdate() { - 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.NewTenantActivityLogAlertsClient().CreateOrUpdate(ctx, "72f988bf-86f1-41af-91ab-2d7cd011db47", "SampleActivityLogAlertSHRuleOnTenantLevel", armalertsmanagement.TenantActivityLogAlertResource{ - Location: to.Ptr("Global"), - Tags: map[string]*string{}, - Properties: &armalertsmanagement.AlertRuleProperties{ - Description: to.Ptr("Description of sample Activity Log Alert service health rule on tenant level events."), - Actions: &armalertsmanagement.ActionList{ - ActionGroups: []*armalertsmanagement.ActionGroup{ - { - ActionGroupID: to.Ptr("/providers/Microsoft.Management/ManagementGroups/72f988bf-86f1-41af-91ab-2d7cd011db47/providers/Microsoft.Insights/actionGroups/SampleActionGroup"), - ActionProperties: map[string]*string{ - "Email.Title": to.Ptr("my email title"), - }, - WebhookProperties: map[string]*string{ - "sampleWebhookProperty": to.Ptr("SamplePropertyValue"), - }, - }}, - }, - Condition: &armalertsmanagement.AlertRuleAllOfCondition{ - AllOf: []*armalertsmanagement.AlertRuleAnyOfOrLeafCondition{ - { - Equals: to.Ptr("ServiceHealth"), - Field: to.Ptr("category"), - }}, - }, - Enabled: to.Ptr(true), - TenantScope: to.Ptr("72f988bf-86f1-41af-91ab-2d7cd011db47"), - }, - }, 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.TenantActivityLogAlertResource = armalertsmanagement.TenantActivityLogAlertResource{ - // Name: to.Ptr("SampleActivityLogAlertSHRuleOnTenantLevel"), - // Type: to.Ptr("Microsoft.AlertsManagement/TenantActivityLogAlerts"), - // ID: to.Ptr("/providers/Microsoft.Management/ManagementGroups/72f988bf-86f1-41af-91ab-2d7cd011db47/providers/Microsoft.AlertsManagement/TenantActivityLogAlerts/SampleActivityLogAlertSHRuleOnTenantLevel"), - // Location: to.Ptr("Global"), - // Tags: map[string]*string{ - // }, - // Properties: &armalertsmanagement.AlertRuleProperties{ - // Description: to.Ptr("Description of sample Activity Log Alert service health rule on tenant level events."), - // Actions: &armalertsmanagement.ActionList{ - // ActionGroups: []*armalertsmanagement.ActionGroup{ - // { - // ActionGroupID: to.Ptr("/providers/Microsoft.Management/ManagementGroups/72f988bf-86f1-41af-91ab-2d7cd011db47/providers/Microsoft.Insights/actionGroups/SampleActionGroup"), - // ActionProperties: map[string]*string{ - // "Email.Title": to.Ptr("my email title"), - // }, - // WebhookProperties: map[string]*string{ - // "sampleWebhookProperty": to.Ptr("SamplePropertyValue"), - // }, - // }}, - // }, - // Condition: &armalertsmanagement.AlertRuleAllOfCondition{ - // AllOf: []*armalertsmanagement.AlertRuleAnyOfOrLeafCondition{ - // { - // Equals: to.Ptr("ServiceHealth"), - // Field: to.Ptr("category"), - // }}, - // }, - // Enabled: to.Ptr(true), - // TenantScope: to.Ptr("72f988bf-86f1-41af-91ab-2d7cd011db47"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/6d2438481021a94793b07b226df06d5f3c61d51d/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-04-01-preview/examples/TenantActivityLogAlertRule_GetRule.json -func ExampleTenantActivityLogAlertsClient_Get() { - 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.NewTenantActivityLogAlertsClient().Get(ctx, "72f988bf-86f1-41af-91ab-2d7cd011db47", "SampleActivityLogAlertSHRuleOnTenantLevel", 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.TenantActivityLogAlertResource = armalertsmanagement.TenantActivityLogAlertResource{ - // Name: to.Ptr("SampleActivityLogAlertSHRuleOnTenantLevel"), - // Type: to.Ptr("Microsoft.AlertsManagement/TenantActivityLogAlerts"), - // ID: to.Ptr("/providers/Microsoft.Management/ManagementGroups/72f988bf-86f1-41af-91ab-2d7cd011db47/providers/Microsoft.AlertsManagement/TenantActivityLogAlerts/SampleActivityLogAlertSHRuleOnTenantLevel"), - // Location: to.Ptr("Global"), - // Tags: map[string]*string{ - // }, - // Properties: &armalertsmanagement.AlertRuleProperties{ - // Description: to.Ptr("Description of sample Activity Log Alert service health rule on tenant level events."), - // Actions: &armalertsmanagement.ActionList{ - // ActionGroups: []*armalertsmanagement.ActionGroup{ - // { - // ActionGroupID: to.Ptr("/providers/Microsoft.Management/ManagementGroups/72f988bf-86f1-41af-91ab-2d7cd011db47/providers/Microsoft.Insights/actionGroups/SampleActionGroup"), - // ActionProperties: map[string]*string{ - // "Email.Title": to.Ptr("my email title"), - // }, - // WebhookProperties: map[string]*string{ - // "sampleWebhookProperty": to.Ptr("SamplePropertyValue"), - // }, - // }}, - // }, - // Condition: &armalertsmanagement.AlertRuleAllOfCondition{ - // AllOf: []*armalertsmanagement.AlertRuleAnyOfOrLeafCondition{ - // { - // Equals: to.Ptr("ServiceHealth"), - // Field: to.Ptr("category"), - // }}, - // }, - // Enabled: to.Ptr(true), - // TenantScope: to.Ptr("72f988bf-86f1-41af-91ab-2d7cd011db47"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/6d2438481021a94793b07b226df06d5f3c61d51d/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-04-01-preview/examples/TenantActivityLogAlertRule_DeleteRule.json -func ExampleTenantActivityLogAlertsClient_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.NewTenantActivityLogAlertsClient().Delete(ctx, "72f988bf-86f1-41af-91ab-2d7cd011db47", "SampleActivityLogAlertSHRuleOnTenantLevel", 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/6d2438481021a94793b07b226df06d5f3c61d51d/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-04-01-preview/examples/TenantActivityLogAlertRule_UpdateRule.json -func ExampleTenantActivityLogAlertsClient_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.NewTenantActivityLogAlertsClient().Update(ctx, "72f988bf-86f1-41af-91ab-2d7cd011db47", "SampleActivityLogAlertSHRuleOnTenantLevel", armalertsmanagement.TenantAlertRulePatchObject{ - Properties: &armalertsmanagement.TenantAlertRulePatchProperties{ - 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.TenantActivityLogAlertResource = armalertsmanagement.TenantActivityLogAlertResource{ - // Name: to.Ptr("SampleActivityLogAlertSHRuleOnTenantLevel"), - // Type: to.Ptr("Microsoft.AlertsManagement/TenantActivityLogAlerts"), - // ID: to.Ptr("/providers/Microsoft.Management/ManagementGroups/72f988bf-86f1-41af-91ab-2d7cd011db47/providers/Microsoft.AlertsManagement/TenantActivityLogAlerts/SampleActivityLogAlertSHRuleOnTenantLevel"), - // Location: to.Ptr("Global"), - // Tags: map[string]*string{ - // "key1": to.Ptr("value1"), - // "key2": to.Ptr("value2"), - // }, - // Properties: &armalertsmanagement.AlertRuleProperties{ - // Description: to.Ptr("Description of sample Activity Log Alert service health rule on tenant level events."), - // Actions: &armalertsmanagement.ActionList{ - // ActionGroups: []*armalertsmanagement.ActionGroup{ - // { - // ActionGroupID: to.Ptr("/providers/Microsoft.Management/ManagementGroups/72f988bf-86f1-41af-91ab-2d7cd011db47/providers/Microsoft.Insights/actionGroups/SampleActionGroup"), - // ActionProperties: map[string]*string{ - // "Email.Title": to.Ptr("my email title"), - // }, - // WebhookProperties: map[string]*string{ - // "sampleWebhookProperty": to.Ptr("SamplePropertyValue"), - // }, - // }}, - // }, - // Condition: &armalertsmanagement.AlertRuleAllOfCondition{ - // AllOf: []*armalertsmanagement.AlertRuleAnyOfOrLeafCondition{ - // { - // Equals: to.Ptr("ServiceHealth"), - // Field: to.Ptr("category"), - // }}, - // }, - // Enabled: to.Ptr(false), - // TenantScope: to.Ptr("72f988bf-86f1-41af-91ab-2d7cd011db47"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/6d2438481021a94793b07b226df06d5f3c61d51d/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-04-01-preview/examples/TenantActivityLogAlertRule_ListByTenant.json -func ExampleTenantActivityLogAlertsClient_NewListByTenantPager() { - 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.NewTenantActivityLogAlertsClient().NewListByTenantPager(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.TenantAlertRuleList = armalertsmanagement.TenantAlertRuleList{ - // Value: []*armalertsmanagement.TenantActivityLogAlertResource{ - // { - // Name: to.Ptr("SampleActivityLogAlertSHRuleOnTenantLevel"), - // Type: to.Ptr("Microsoft.AlertsManagement/TenantActivityLogAlerts"), - // ID: to.Ptr("/providers/Microsoft.Management/ManagementGroups/72f988bf-86f1-41af-91ab-2d7cd011db47/providers/Microsoft.AlertsManagement/TenantActivityLogAlerts/SampleActivityLogAlertSHRuleOnTenantLevel"), - // Location: to.Ptr("Global"), - // Tags: map[string]*string{ - // }, - // Properties: &armalertsmanagement.AlertRuleProperties{ - // Description: to.Ptr("Description of sample Activity Log Alert service health rule on tenant level events."), - // Actions: &armalertsmanagement.ActionList{ - // ActionGroups: []*armalertsmanagement.ActionGroup{ - // { - // ActionGroupID: to.Ptr("/providers/Microsoft.Management/ManagementGroups/72f988bf-86f1-41af-91ab-2d7cd011db47/providers/Microsoft.Insights/actionGroups/SampleActionGroup"), - // ActionProperties: map[string]*string{ - // "Email.Title": to.Ptr("my email title"), - // }, - // WebhookProperties: map[string]*string{ - // "sampleWebhookProperty": to.Ptr("SamplePropertyValue"), - // }, - // }}, - // }, - // Condition: &armalertsmanagement.AlertRuleAllOfCondition{ - // AllOf: []*armalertsmanagement.AlertRuleAnyOfOrLeafCondition{ - // { - // Equals: to.Ptr("ServiceHealth"), - // Field: to.Ptr("category"), - // }}, - // }, - // Enabled: to.Ptr(true), - // TenantScope: to.Ptr("72f988bf-86f1-41af-91ab-2d7cd011db47"), - // }, - // }, - // { - // Name: to.Ptr("SampleActivityLogAlertSHRuleOnTenantLevel"), - // Type: to.Ptr("Microsoft.AlertsManagement/TenantActivityLogAlerts"), - // ID: to.Ptr("/providers/Microsoft.Management/ManagementGroups/MyManagementGroup/providers/Microsoft.AlertsManagement/TenantActivityLogAlerts/SampleActivityLogAlertSHRuleOnTenantLevel"), - // Location: to.Ptr("Global"), - // Tags: map[string]*string{ - // }, - // Properties: &armalertsmanagement.AlertRuleProperties{ - // Description: to.Ptr("Description of sample Activity Log Alert service health rule on tenant level events."), - // Actions: &armalertsmanagement.ActionList{ - // ActionGroups: []*armalertsmanagement.ActionGroup{ - // { - // ActionGroupID: to.Ptr("/providers/Microsoft.Management/ManagementGroups/MyManagementGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup"), - // ActionProperties: map[string]*string{ - // "Email.Title": to.Ptr("my email title"), - // }, - // WebhookProperties: map[string]*string{ - // "sampleWebhookProperty": to.Ptr("SamplePropertyValue"), - // }, - // }}, - // }, - // Condition: &armalertsmanagement.AlertRuleAllOfCondition{ - // AllOf: []*armalertsmanagement.AlertRuleAnyOfOrLeafCondition{ - // { - // Equals: to.Ptr("ServiceHealth"), - // Field: to.Ptr("category"), - // }}, - // }, - // Enabled: to.Ptr(true), - // TenantScope: to.Ptr("72f988bf-86f1-41af-91ab-2d7cd011db47"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/6d2438481021a94793b07b226df06d5f3c61d51d/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-04-01-preview/examples/TenantActivityLogAlertRule_ListByManagementGroup.json -func ExampleTenantActivityLogAlertsClient_NewListByManagementGroupPager() { - 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.NewTenantActivityLogAlertsClient().NewListByManagementGroupPager("72f988bf-86f1-41af-91ab-2d7cd011db47", 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.TenantAlertRuleList = armalertsmanagement.TenantAlertRuleList{ - // Value: []*armalertsmanagement.TenantActivityLogAlertResource{ - // { - // Name: to.Ptr("SampleActivityLogAlertSHRuleOnTenantLevel"), - // Type: to.Ptr("Microsoft.AlertsManagement/TenantActivityLogAlerts"), - // ID: to.Ptr("/providers/Microsoft.Management/ManagementGroups/72f988bf-86f1-41af-91ab-2d7cd011db47/providers/Microsoft.AlertsManagement/TenantActivityLogAlerts/SampleActivityLogAlertSHRuleOnTenantLevel"), - // Location: to.Ptr("Global"), - // Tags: map[string]*string{ - // }, - // Properties: &armalertsmanagement.AlertRuleProperties{ - // Description: to.Ptr("Description of sample Activity Log Alert service health rule on tenant level events."), - // Actions: &armalertsmanagement.ActionList{ - // ActionGroups: []*armalertsmanagement.ActionGroup{ - // { - // ActionGroupID: to.Ptr("/providers/Microsoft.Management/ManagementGroups/72f988bf-86f1-41af-91ab-2d7cd011db47/providers/Microsoft.Insights/actionGroups/SampleActionGroup"), - // ActionProperties: map[string]*string{ - // "Email.Title": to.Ptr("my email title"), - // }, - // WebhookProperties: map[string]*string{ - // "sampleWebhookProperty": to.Ptr("SamplePropertyValue"), - // }, - // }}, - // }, - // Condition: &armalertsmanagement.AlertRuleAllOfCondition{ - // AllOf: []*armalertsmanagement.AlertRuleAnyOfOrLeafCondition{ - // { - // Equals: to.Ptr("ServiceHealth"), - // Field: to.Ptr("category"), - // }}, - // }, - // Enabled: to.Ptr(true), - // TenantScope: to.Ptr("72f988bf-86f1-41af-91ab-2d7cd011db47"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/time_rfc3339.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/time_rfc3339.go index baccd3c76435..f76559bcf24b 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/time_rfc3339.go +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/time_rfc3339.go @@ -1,6 +1,3 @@ -//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. @@ -60,6 +57,9 @@ func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { } func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + if len(data) == 0 { + return nil + } tzOffset := tzOffsetRegex.Match(data) hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") var layout string