diff --git a/profiles/latest/alertsmanagement/mgmt/alertsmanagement/alertsmanagementapi/models.go b/profiles/latest/alertsmanagement/mgmt/alertsmanagement/alertsmanagementapi/models.go index b81b0d37c69b..951ae0f21a84 100644 --- a/profiles/latest/alertsmanagement/mgmt/alertsmanagement/alertsmanagementapi/models.go +++ b/profiles/latest/alertsmanagement/mgmt/alertsmanagement/alertsmanagementapi/models.go @@ -19,8 +19,9 @@ package alertsmanagementapi -import original "github.com/Azure/azure-sdk-for-go/services/alertsmanagement/mgmt/2018-05-05/alertsmanagement/alertsmanagementapi" +import original "github.com/Azure/azure-sdk-for-go/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/alertsmanagementapi" type AlertsClientAPI = original.AlertsClientAPI type OperationsClientAPI = original.OperationsClientAPI +type SmartDetectorAlertRulesClientAPI = original.SmartDetectorAlertRulesClientAPI type SmartGroupsClientAPI = original.SmartGroupsClientAPI diff --git a/profiles/latest/alertsmanagement/mgmt/alertsmanagement/models.go b/profiles/latest/alertsmanagement/mgmt/alertsmanagement/models.go index 25d5f9997f4b..e2352cdf013c 100644 --- a/profiles/latest/alertsmanagement/mgmt/alertsmanagement/models.go +++ b/profiles/latest/alertsmanagement/mgmt/alertsmanagement/models.go @@ -22,7 +22,7 @@ package alertsmanagement import ( "context" - original "github.com/Azure/azure-sdk-for-go/services/alertsmanagement/mgmt/2018-05-05/alertsmanagement" + original "github.com/Azure/azure-sdk-for-go/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement" ) const ( @@ -37,6 +37,13 @@ const ( StateChange AlertModificationEvent = original.StateChange ) +type AlertRuleState = original.AlertRuleState + +const ( + Disabled AlertRuleState = original.Disabled + Enabled AlertRuleState = original.Enabled +) + type AlertState = original.AlertState const ( @@ -90,6 +97,7 @@ const ( LogAnalytics MonitorService = original.LogAnalytics Nagios MonitorService = original.Nagios Platform MonitorService = original.Platform + ResourceHealth MonitorService = original.ResourceHealth SCOM MonitorService = original.SCOM ServiceHealth MonitorService = original.ServiceHealth SmartDetector MonitorService = original.SmartDetector @@ -151,11 +159,17 @@ const ( ThreeZerod TimeRange = original.ThreeZerod ) +type ActionGroupsInformation = original.ActionGroupsInformation type Alert = original.Alert type AlertModification = original.AlertModification type AlertModificationItem = original.AlertModificationItem type AlertModificationProperties = original.AlertModificationProperties type AlertProperties = original.AlertProperties +type AlertRule = original.AlertRule +type AlertRuleProperties = original.AlertRuleProperties +type AlertRulesList = original.AlertRulesList +type AlertRulesListIterator = original.AlertRulesListIterator +type AlertRulesListPage = original.AlertRulesListPage type AlertsClient = original.AlertsClient type AlertsList = original.AlertsList type AlertsListIterator = original.AlertsListIterator @@ -163,8 +177,11 @@ type AlertsListPage = original.AlertsListPage type AlertsSummary = original.AlertsSummary type AlertsSummaryGroup = original.AlertsSummaryGroup type AlertsSummaryGroupItem = original.AlertsSummaryGroupItem +type AzureResource = original.AzureResource type BaseClient = original.BaseClient +type Detector = original.Detector type ErrorResponse = original.ErrorResponse +type ErrorResponse1 = original.ErrorResponse1 type ErrorResponseBody = original.ErrorResponseBody type Essentials = original.Essentials type Operation = original.Operation @@ -173,7 +190,8 @@ type OperationsClient = original.OperationsClient type OperationsList = original.OperationsList type OperationsListIterator = original.OperationsListIterator type OperationsListPage = original.OperationsListPage -type Resource = original.Resource +type ProxyResource = original.ProxyResource +type SmartDetectorAlertRulesClient = original.SmartDetectorAlertRulesClient type SmartGroup = original.SmartGroup type SmartGroupAggregatedProperty = original.SmartGroupAggregatedProperty type SmartGroupModification = original.SmartGroupModification @@ -182,17 +200,22 @@ type SmartGroupModificationProperties = original.SmartGroupModificationPropertie type SmartGroupProperties = original.SmartGroupProperties type SmartGroupsClient = original.SmartGroupsClient type SmartGroupsList = original.SmartGroupsList -type SmartGroupsListIterator = original.SmartGroupsListIterator -type SmartGroupsListPage = original.SmartGroupsListPage +type ThrottlingInformation = original.ThrottlingInformation -func New(subscriptionID string) BaseClient { - return original.New(subscriptionID) +func New(scope string, subscriptionID string, subscriptionID1 string) BaseClient { + return original.New(scope, subscriptionID, subscriptionID1) } -func NewAlertsClient(subscriptionID string) AlertsClient { - return original.NewAlertsClient(subscriptionID) +func NewAlertRulesListIterator(page AlertRulesListPage) AlertRulesListIterator { + return original.NewAlertRulesListIterator(page) } -func NewAlertsClientWithBaseURI(baseURI string, subscriptionID string) AlertsClient { - return original.NewAlertsClientWithBaseURI(baseURI, subscriptionID) +func NewAlertRulesListPage(getNextPage func(context.Context, AlertRulesList) (AlertRulesList, error)) AlertRulesListPage { + return original.NewAlertRulesListPage(getNextPage) +} +func NewAlertsClient(scope string, subscriptionID string, subscriptionID1 string) AlertsClient { + return original.NewAlertsClient(scope, subscriptionID, subscriptionID1) +} +func NewAlertsClientWithBaseURI(baseURI string, scope string, subscriptionID string, subscriptionID1 string) AlertsClient { + return original.NewAlertsClientWithBaseURI(baseURI, scope, subscriptionID, subscriptionID1) } func NewAlertsListIterator(page AlertsListPage) AlertsListIterator { return original.NewAlertsListIterator(page) @@ -200,11 +223,11 @@ func NewAlertsListIterator(page AlertsListPage) AlertsListIterator { func NewAlertsListPage(getNextPage func(context.Context, AlertsList) (AlertsList, error)) AlertsListPage { return original.NewAlertsListPage(getNextPage) } -func NewOperationsClient(subscriptionID string) OperationsClient { - return original.NewOperationsClient(subscriptionID) +func NewOperationsClient(scope string, subscriptionID string, subscriptionID1 string) OperationsClient { + return original.NewOperationsClient(scope, subscriptionID, subscriptionID1) } -func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { - return original.NewOperationsClientWithBaseURI(baseURI, subscriptionID) +func NewOperationsClientWithBaseURI(baseURI string, scope string, subscriptionID string, subscriptionID1 string) OperationsClient { + return original.NewOperationsClientWithBaseURI(baseURI, scope, subscriptionID, subscriptionID1) } func NewOperationsListIterator(page OperationsListPage) OperationsListIterator { return original.NewOperationsListIterator(page) @@ -212,24 +235,27 @@ func NewOperationsListIterator(page OperationsListPage) OperationsListIterator { func NewOperationsListPage(getNextPage func(context.Context, OperationsList) (OperationsList, error)) OperationsListPage { return original.NewOperationsListPage(getNextPage) } -func NewSmartGroupsClient(subscriptionID string) SmartGroupsClient { - return original.NewSmartGroupsClient(subscriptionID) +func NewSmartDetectorAlertRulesClient(scope string, subscriptionID string, subscriptionID1 string) SmartDetectorAlertRulesClient { + return original.NewSmartDetectorAlertRulesClient(scope, subscriptionID, subscriptionID1) } -func NewSmartGroupsClientWithBaseURI(baseURI string, subscriptionID string) SmartGroupsClient { - return original.NewSmartGroupsClientWithBaseURI(baseURI, subscriptionID) +func NewSmartDetectorAlertRulesClientWithBaseURI(baseURI string, scope string, subscriptionID string, subscriptionID1 string) SmartDetectorAlertRulesClient { + return original.NewSmartDetectorAlertRulesClientWithBaseURI(baseURI, scope, subscriptionID, subscriptionID1) } -func NewSmartGroupsListIterator(page SmartGroupsListPage) SmartGroupsListIterator { - return original.NewSmartGroupsListIterator(page) +func NewSmartGroupsClient(scope string, subscriptionID string, subscriptionID1 string) SmartGroupsClient { + return original.NewSmartGroupsClient(scope, subscriptionID, subscriptionID1) } -func NewSmartGroupsListPage(getNextPage func(context.Context, SmartGroupsList) (SmartGroupsList, error)) SmartGroupsListPage { - return original.NewSmartGroupsListPage(getNextPage) +func NewSmartGroupsClientWithBaseURI(baseURI string, scope string, subscriptionID string, subscriptionID1 string) SmartGroupsClient { + return original.NewSmartGroupsClientWithBaseURI(baseURI, scope, subscriptionID, subscriptionID1) } -func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { - return original.NewWithBaseURI(baseURI, subscriptionID) +func NewWithBaseURI(baseURI string, scope string, subscriptionID string, subscriptionID1 string) BaseClient { + return original.NewWithBaseURI(baseURI, scope, subscriptionID, subscriptionID1) } func PossibleAlertModificationEventValues() []AlertModificationEvent { return original.PossibleAlertModificationEventValues() } +func PossibleAlertRuleStateValues() []AlertRuleState { + return original.PossibleAlertRuleStateValues() +} func PossibleAlertStateValues() []AlertState { return original.PossibleAlertStateValues() } diff --git a/profiles/preview/alertsmanagement/mgmt/alertsmanagement/alertsmanagementapi/models.go b/profiles/preview/alertsmanagement/mgmt/alertsmanagement/alertsmanagementapi/models.go index b81b0d37c69b..951ae0f21a84 100644 --- a/profiles/preview/alertsmanagement/mgmt/alertsmanagement/alertsmanagementapi/models.go +++ b/profiles/preview/alertsmanagement/mgmt/alertsmanagement/alertsmanagementapi/models.go @@ -19,8 +19,9 @@ package alertsmanagementapi -import original "github.com/Azure/azure-sdk-for-go/services/alertsmanagement/mgmt/2018-05-05/alertsmanagement/alertsmanagementapi" +import original "github.com/Azure/azure-sdk-for-go/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/alertsmanagementapi" type AlertsClientAPI = original.AlertsClientAPI type OperationsClientAPI = original.OperationsClientAPI +type SmartDetectorAlertRulesClientAPI = original.SmartDetectorAlertRulesClientAPI type SmartGroupsClientAPI = original.SmartGroupsClientAPI diff --git a/profiles/preview/alertsmanagement/mgmt/alertsmanagement/models.go b/profiles/preview/alertsmanagement/mgmt/alertsmanagement/models.go index 2d8878aedc55..b9d10af1e3ae 100644 --- a/profiles/preview/alertsmanagement/mgmt/alertsmanagement/models.go +++ b/profiles/preview/alertsmanagement/mgmt/alertsmanagement/models.go @@ -22,7 +22,7 @@ package alertsmanagement import ( "context" - original "github.com/Azure/azure-sdk-for-go/services/alertsmanagement/mgmt/2018-05-05/alertsmanagement" + original "github.com/Azure/azure-sdk-for-go/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement" ) const ( @@ -37,6 +37,13 @@ const ( StateChange AlertModificationEvent = original.StateChange ) +type AlertRuleState = original.AlertRuleState + +const ( + Disabled AlertRuleState = original.Disabled + Enabled AlertRuleState = original.Enabled +) + type AlertState = original.AlertState const ( @@ -90,6 +97,7 @@ const ( LogAnalytics MonitorService = original.LogAnalytics Nagios MonitorService = original.Nagios Platform MonitorService = original.Platform + ResourceHealth MonitorService = original.ResourceHealth SCOM MonitorService = original.SCOM ServiceHealth MonitorService = original.ServiceHealth SmartDetector MonitorService = original.SmartDetector @@ -151,11 +159,17 @@ const ( ThreeZerod TimeRange = original.ThreeZerod ) +type ActionGroupsInformation = original.ActionGroupsInformation type Alert = original.Alert type AlertModification = original.AlertModification type AlertModificationItem = original.AlertModificationItem type AlertModificationProperties = original.AlertModificationProperties type AlertProperties = original.AlertProperties +type AlertRule = original.AlertRule +type AlertRuleProperties = original.AlertRuleProperties +type AlertRulesList = original.AlertRulesList +type AlertRulesListIterator = original.AlertRulesListIterator +type AlertRulesListPage = original.AlertRulesListPage type AlertsClient = original.AlertsClient type AlertsList = original.AlertsList type AlertsListIterator = original.AlertsListIterator @@ -163,8 +177,11 @@ type AlertsListPage = original.AlertsListPage type AlertsSummary = original.AlertsSummary type AlertsSummaryGroup = original.AlertsSummaryGroup type AlertsSummaryGroupItem = original.AlertsSummaryGroupItem +type AzureResource = original.AzureResource type BaseClient = original.BaseClient +type Detector = original.Detector type ErrorResponse = original.ErrorResponse +type ErrorResponse1 = original.ErrorResponse1 type ErrorResponseBody = original.ErrorResponseBody type Essentials = original.Essentials type Operation = original.Operation @@ -173,7 +190,8 @@ type OperationsClient = original.OperationsClient type OperationsList = original.OperationsList type OperationsListIterator = original.OperationsListIterator type OperationsListPage = original.OperationsListPage -type Resource = original.Resource +type ProxyResource = original.ProxyResource +type SmartDetectorAlertRulesClient = original.SmartDetectorAlertRulesClient type SmartGroup = original.SmartGroup type SmartGroupAggregatedProperty = original.SmartGroupAggregatedProperty type SmartGroupModification = original.SmartGroupModification @@ -182,17 +200,22 @@ type SmartGroupModificationProperties = original.SmartGroupModificationPropertie type SmartGroupProperties = original.SmartGroupProperties type SmartGroupsClient = original.SmartGroupsClient type SmartGroupsList = original.SmartGroupsList -type SmartGroupsListIterator = original.SmartGroupsListIterator -type SmartGroupsListPage = original.SmartGroupsListPage +type ThrottlingInformation = original.ThrottlingInformation -func New(subscriptionID string) BaseClient { - return original.New(subscriptionID) +func New(scope string, subscriptionID string, subscriptionID1 string) BaseClient { + return original.New(scope, subscriptionID, subscriptionID1) } -func NewAlertsClient(subscriptionID string) AlertsClient { - return original.NewAlertsClient(subscriptionID) +func NewAlertRulesListIterator(page AlertRulesListPage) AlertRulesListIterator { + return original.NewAlertRulesListIterator(page) } -func NewAlertsClientWithBaseURI(baseURI string, subscriptionID string) AlertsClient { - return original.NewAlertsClientWithBaseURI(baseURI, subscriptionID) +func NewAlertRulesListPage(getNextPage func(context.Context, AlertRulesList) (AlertRulesList, error)) AlertRulesListPage { + return original.NewAlertRulesListPage(getNextPage) +} +func NewAlertsClient(scope string, subscriptionID string, subscriptionID1 string) AlertsClient { + return original.NewAlertsClient(scope, subscriptionID, subscriptionID1) +} +func NewAlertsClientWithBaseURI(baseURI string, scope string, subscriptionID string, subscriptionID1 string) AlertsClient { + return original.NewAlertsClientWithBaseURI(baseURI, scope, subscriptionID, subscriptionID1) } func NewAlertsListIterator(page AlertsListPage) AlertsListIterator { return original.NewAlertsListIterator(page) @@ -200,11 +223,11 @@ func NewAlertsListIterator(page AlertsListPage) AlertsListIterator { func NewAlertsListPage(getNextPage func(context.Context, AlertsList) (AlertsList, error)) AlertsListPage { return original.NewAlertsListPage(getNextPage) } -func NewOperationsClient(subscriptionID string) OperationsClient { - return original.NewOperationsClient(subscriptionID) +func NewOperationsClient(scope string, subscriptionID string, subscriptionID1 string) OperationsClient { + return original.NewOperationsClient(scope, subscriptionID, subscriptionID1) } -func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { - return original.NewOperationsClientWithBaseURI(baseURI, subscriptionID) +func NewOperationsClientWithBaseURI(baseURI string, scope string, subscriptionID string, subscriptionID1 string) OperationsClient { + return original.NewOperationsClientWithBaseURI(baseURI, scope, subscriptionID, subscriptionID1) } func NewOperationsListIterator(page OperationsListPage) OperationsListIterator { return original.NewOperationsListIterator(page) @@ -212,24 +235,27 @@ func NewOperationsListIterator(page OperationsListPage) OperationsListIterator { func NewOperationsListPage(getNextPage func(context.Context, OperationsList) (OperationsList, error)) OperationsListPage { return original.NewOperationsListPage(getNextPage) } -func NewSmartGroupsClient(subscriptionID string) SmartGroupsClient { - return original.NewSmartGroupsClient(subscriptionID) +func NewSmartDetectorAlertRulesClient(scope string, subscriptionID string, subscriptionID1 string) SmartDetectorAlertRulesClient { + return original.NewSmartDetectorAlertRulesClient(scope, subscriptionID, subscriptionID1) } -func NewSmartGroupsClientWithBaseURI(baseURI string, subscriptionID string) SmartGroupsClient { - return original.NewSmartGroupsClientWithBaseURI(baseURI, subscriptionID) +func NewSmartDetectorAlertRulesClientWithBaseURI(baseURI string, scope string, subscriptionID string, subscriptionID1 string) SmartDetectorAlertRulesClient { + return original.NewSmartDetectorAlertRulesClientWithBaseURI(baseURI, scope, subscriptionID, subscriptionID1) } -func NewSmartGroupsListIterator(page SmartGroupsListPage) SmartGroupsListIterator { - return original.NewSmartGroupsListIterator(page) +func NewSmartGroupsClient(scope string, subscriptionID string, subscriptionID1 string) SmartGroupsClient { + return original.NewSmartGroupsClient(scope, subscriptionID, subscriptionID1) } -func NewSmartGroupsListPage(getNextPage func(context.Context, SmartGroupsList) (SmartGroupsList, error)) SmartGroupsListPage { - return original.NewSmartGroupsListPage(getNextPage) +func NewSmartGroupsClientWithBaseURI(baseURI string, scope string, subscriptionID string, subscriptionID1 string) SmartGroupsClient { + return original.NewSmartGroupsClientWithBaseURI(baseURI, scope, subscriptionID, subscriptionID1) } -func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { - return original.NewWithBaseURI(baseURI, subscriptionID) +func NewWithBaseURI(baseURI string, scope string, subscriptionID string, subscriptionID1 string) BaseClient { + return original.NewWithBaseURI(baseURI, scope, subscriptionID, subscriptionID1) } func PossibleAlertModificationEventValues() []AlertModificationEvent { return original.PossibleAlertModificationEventValues() } +func PossibleAlertRuleStateValues() []AlertRuleState { + return original.PossibleAlertRuleStateValues() +} func PossibleAlertStateValues() []AlertState { return original.PossibleAlertStateValues() } diff --git a/profiles/preview/preview/alertsmanagement/mgmt/alertsmanagement/models.go b/profiles/preview/preview/alertsmanagement/mgmt/alertsmanagement/models.go index ac0313d8bbbd..e2b1c943c285 100644 --- a/profiles/preview/preview/alertsmanagement/mgmt/alertsmanagement/models.go +++ b/profiles/preview/preview/alertsmanagement/mgmt/alertsmanagement/models.go @@ -26,7 +26,8 @@ import ( ) const ( - DefaultBaseURI = original.DefaultBaseURI + DefaultBaseURI = original.DefaultBaseURI + DefaultIdentifier = original.DefaultIdentifier ) type ActionRuleStatus = original.ActionRuleStatus @@ -78,6 +79,13 @@ const ( AlertsSummaryGroupByFieldsSignalType AlertsSummaryGroupByFields = original.AlertsSummaryGroupByFieldsSignalType ) +type MetadataIdentifier = original.MetadataIdentifier + +const ( + MetadataIdentifierAlertsMetaDataProperties MetadataIdentifier = original.MetadataIdentifierAlertsMetaDataProperties + MetadataIdentifierMonitorServiceList MetadataIdentifier = original.MetadataIdentifierMonitorServiceList +) + type MonitorCondition = original.MonitorCondition const ( @@ -209,11 +217,14 @@ type AlertsClient = original.AlertsClient type AlertsList = original.AlertsList type AlertsListIterator = original.AlertsListIterator type AlertsListPage = original.AlertsListPage +type AlertsMetaData = original.AlertsMetaData +type AlertsMetaDataProperties = original.AlertsMetaDataProperties type AlertsSummary = original.AlertsSummary type AlertsSummaryGroup = original.AlertsSummaryGroup type AlertsSummaryGroupItem = original.AlertsSummaryGroupItem type BaseClient = original.BaseClient type BasicActionRuleProperties = original.BasicActionRuleProperties +type BasicAlertsMetaDataProperties = original.BasicAlertsMetaDataProperties type Bool = original.Bool type Condition = original.Condition type Conditions = original.Conditions @@ -222,6 +233,8 @@ type ErrorResponse = original.ErrorResponse type ErrorResponseBody = original.ErrorResponseBody type Essentials = original.Essentials type ManagedResource = original.ManagedResource +type MonitorServiceDetails = original.MonitorServiceDetails +type MonitorServiceList = original.MonitorServiceList type Operation = original.Operation type OperationDisplay = original.OperationDisplay type OperationsClient = original.OperationsClient @@ -315,6 +328,9 @@ func PossibleAlertsSortByFieldsValues() []AlertsSortByFields { func PossibleAlertsSummaryGroupByFieldsValues() []AlertsSummaryGroupByFields { return original.PossibleAlertsSummaryGroupByFieldsValues() } +func PossibleMetadataIdentifierValues() []MetadataIdentifier { + return original.PossibleMetadataIdentifierValues() +} func PossibleMonitorConditionValues() []MonitorCondition { return original.PossibleMonitorConditionValues() } diff --git a/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/alerts.go b/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/alerts.go new file mode 100644 index 000000000000..faca95b9b66c --- /dev/null +++ b/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/alerts.go @@ -0,0 +1,597 @@ +package alertsmanagement + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// AlertsClient is the alertsManagement Client +type AlertsClient struct { + BaseClient +} + +// NewAlertsClient creates an instance of the AlertsClient client. +func NewAlertsClient(scope string, subscriptionID string, subscriptionID1 string) AlertsClient { + return NewAlertsClientWithBaseURI(DefaultBaseURI, scope, subscriptionID, subscriptionID1) +} + +// NewAlertsClientWithBaseURI creates an instance of the AlertsClient client. +func NewAlertsClientWithBaseURI(baseURI string, scope string, subscriptionID string, subscriptionID1 string) AlertsClient { + return AlertsClient{NewWithBaseURI(baseURI, scope, subscriptionID, subscriptionID1)} +} + +// ChangeState change the state of an alert. If scope is a deleted resource then please use scope as parent resource of +// the delete resource. For example if my alert id is +// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/virtualMachines/vm1/providers/Microsoft.AlertsManagement/alerts/{alertId}' +// and 'vm1' is deleted then if you want to change state of this particular alert then use parent resource of scope. So +// in this example change state call will look like this: +// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AlertsManagement/alerts/{alertId}'. +// Parameters: +// alertID - unique ID of an alert instance. +// newState - new state of the alert. +func (client AlertsClient) ChangeState(ctx context.Context, alertID string, newState AlertState) (result Alert, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.ChangeState") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ChangeStatePreparer(ctx, alertID, newState) + if err != nil { + err = autorest.NewErrorWithError(err, "alertsmanagement.AlertsClient", "ChangeState", nil, "Failure preparing request") + return + } + + resp, err := client.ChangeStateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "alertsmanagement.AlertsClient", "ChangeState", resp, "Failure sending request") + return + } + + result, err = client.ChangeStateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "alertsmanagement.AlertsClient", "ChangeState", resp, "Failure responding to request") + } + + return +} + +// ChangeStatePreparer prepares the ChangeState request. +func (client AlertsClient) ChangeStatePreparer(ctx context.Context, alertID string, newState AlertState) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "alertId": autorest.Encode("path", alertID), + "scope": client.Scope, + } + + const APIVersion = "2018-05-05" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + "newState": autorest.Encode("query", newState), + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.AlertsManagement/alerts/{alertId}/changestate", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ChangeStateSender sends the ChangeState request. The method will close the +// http.Response Body if it receives an error. +func (client AlertsClient) ChangeStateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ChangeStateResponder handles the response to the ChangeState request. The method always +// closes the http.Response Body. +func (client AlertsClient) ChangeStateResponder(resp *http.Response) (result Alert, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetAll list all existing alerts, where the results can be filtered on the basis of multiple parameters (e.g. time +// range). The results can then be sorted on the basis specific fields, with the default being lastModifiedDateTime. +// Parameters: +// targetResource - filter by target resource( which is full ARM ID) Default value is select all. +// targetResourceType - filter by target resource type. Default value is select all. +// targetResourceGroup - filter by target resource group name. Default value is select all. +// monitorService - filter by monitor service which generates the alert instance. Default value is select all. +// monitorCondition - filter by monitor condition which is either 'Fired' or 'Resolved'. Default value is to +// select all. +// severity - filter by severity. Default value is select all. +// alertState - filter by state of the alert instance. Default value is to select all. +// alertRule - filter by specific alert rule. Default value is to select all. +// smartGroupID - filter the alerts list by the Smart Group Id. Default value is none. +// includeContext - include context which has contextual data specific to the monitor service. Default value is +// false' +// includeEgressConfig - include egress config which would be used for displaying the content in portal. +// Default value is 'false'. +// pageCount - determines number of alerts returned per page in response. Permissible value is between 1 to +// 250. When the "includeContent" filter is selected, maximum value allowed is 25. Default value is 25. +// sortBy - sort the query results by input field, Default value is 'lastModifiedDateTime'. +// sortOrder - sort the query results order in either ascending or descending. Default value is 'desc' for +// time fields and 'asc' for others. +// selectParameter - this filter allows to selection of the fields(comma separated) which would be part of the +// essential section. This would allow to project only the required fields rather than getting entire content. +// Default is to fetch all the fields in the essentials section. +// timeRange - filter by time range by below listed values. Default value is 1 day. +// customTimeRange - filter by custom time range in the format / where time is in +// (ISO-8601 format)'. Permissible values is within 30 days from query time. Either timeRange or +// customTimeRange could be used but not both. Default is none. +func (client AlertsClient) GetAll(ctx context.Context, targetResource string, targetResourceType string, targetResourceGroup string, monitorService MonitorService, monitorCondition MonitorCondition, severity Severity, alertState AlertState, alertRule string, smartGroupID string, includeContext *bool, includeEgressConfig *bool, pageCount *int32, sortBy AlertsSortByFields, sortOrder string, selectParameter string, timeRange TimeRange, customTimeRange string) (result AlertsListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.GetAll") + defer func() { + sc := -1 + if result.al.Response.Response != nil { + sc = result.al.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.getAllNextResults + req, err := client.GetAllPreparer(ctx, targetResource, targetResourceType, targetResourceGroup, monitorService, monitorCondition, severity, alertState, alertRule, smartGroupID, includeContext, includeEgressConfig, pageCount, sortBy, sortOrder, selectParameter, timeRange, customTimeRange) + if err != nil { + err = autorest.NewErrorWithError(err, "alertsmanagement.AlertsClient", "GetAll", nil, "Failure preparing request") + return + } + + resp, err := client.GetAllSender(req) + if err != nil { + result.al.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "alertsmanagement.AlertsClient", "GetAll", resp, "Failure sending request") + return + } + + result.al, err = client.GetAllResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "alertsmanagement.AlertsClient", "GetAll", resp, "Failure responding to request") + } + + return +} + +// GetAllPreparer prepares the GetAll request. +func (client AlertsClient) GetAllPreparer(ctx context.Context, targetResource string, targetResourceType string, targetResourceGroup string, monitorService MonitorService, monitorCondition MonitorCondition, severity Severity, alertState AlertState, alertRule string, smartGroupID string, includeContext *bool, includeEgressConfig *bool, pageCount *int32, sortBy AlertsSortByFields, sortOrder string, selectParameter string, timeRange TimeRange, customTimeRange string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scope": client.Scope, + } + + const APIVersion = "2018-05-05" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(targetResource) > 0 { + queryParameters["targetResource"] = autorest.Encode("query", targetResource) + } + if len(targetResourceType) > 0 { + queryParameters["targetResourceType"] = autorest.Encode("query", targetResourceType) + } + if len(targetResourceGroup) > 0 { + queryParameters["targetResourceGroup"] = autorest.Encode("query", targetResourceGroup) + } + if len(string(monitorService)) > 0 { + queryParameters["monitorService"] = autorest.Encode("query", monitorService) + } + if len(string(monitorCondition)) > 0 { + queryParameters["monitorCondition"] = autorest.Encode("query", monitorCondition) + } + if len(string(severity)) > 0 { + queryParameters["severity"] = autorest.Encode("query", severity) + } + if len(string(alertState)) > 0 { + queryParameters["alertState"] = autorest.Encode("query", alertState) + } + if len(alertRule) > 0 { + queryParameters["alertRule"] = autorest.Encode("query", alertRule) + } + if len(smartGroupID) > 0 { + queryParameters["smartGroupId"] = autorest.Encode("query", smartGroupID) + } + if includeContext != nil { + queryParameters["includeContext"] = autorest.Encode("query", *includeContext) + } + if includeEgressConfig != nil { + queryParameters["includeEgressConfig"] = autorest.Encode("query", *includeEgressConfig) + } + if pageCount != nil { + queryParameters["pageCount"] = autorest.Encode("query", *pageCount) + } + if len(string(sortBy)) > 0 { + queryParameters["sortBy"] = autorest.Encode("query", sortBy) + } + if len(string(sortOrder)) > 0 { + queryParameters["sortOrder"] = autorest.Encode("query", sortOrder) + } + if len(selectParameter) > 0 { + queryParameters["select"] = autorest.Encode("query", selectParameter) + } + if len(string(timeRange)) > 0 { + queryParameters["timeRange"] = autorest.Encode("query", timeRange) + } + if len(customTimeRange) > 0 { + queryParameters["customTimeRange"] = autorest.Encode("query", customTimeRange) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.AlertsManagement/alerts", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetAllSender sends the GetAll request. The method will close the +// http.Response Body if it receives an error. +func (client AlertsClient) GetAllSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetAllResponder handles the response to the GetAll request. The method always +// closes the http.Response Body. +func (client AlertsClient) GetAllResponder(resp *http.Response) (result AlertsList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// getAllNextResults retrieves the next set of results, if any. +func (client AlertsClient) getAllNextResults(ctx context.Context, lastResults AlertsList) (result AlertsList, err error) { + req, err := lastResults.alertsListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "alertsmanagement.AlertsClient", "getAllNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.GetAllSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "alertsmanagement.AlertsClient", "getAllNextResults", resp, "Failure sending next results request") + } + result, err = client.GetAllResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "alertsmanagement.AlertsClient", "getAllNextResults", resp, "Failure responding to next results request") + } + return +} + +// GetAllComplete enumerates all values, automatically crossing page boundaries as required. +func (client AlertsClient) GetAllComplete(ctx context.Context, targetResource string, targetResourceType string, targetResourceGroup string, monitorService MonitorService, monitorCondition MonitorCondition, severity Severity, alertState AlertState, alertRule string, smartGroupID string, includeContext *bool, includeEgressConfig *bool, pageCount *int32, sortBy AlertsSortByFields, sortOrder string, selectParameter string, timeRange TimeRange, customTimeRange string) (result AlertsListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.GetAll") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.GetAll(ctx, targetResource, targetResourceType, targetResourceGroup, monitorService, monitorCondition, severity, alertState, alertRule, smartGroupID, includeContext, includeEgressConfig, pageCount, sortBy, sortOrder, selectParameter, timeRange, customTimeRange) + return +} + +// GetByID get information related to a specific alert. If scope is a deleted resource then please use scope as parent +// resource of the delete resource. For example if my alert id is +// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/virtualMachines/vm1/providers/Microsoft.AlertsManagement/alerts/{alertId}' +// and 'vm1' is deleted then if you want to get alert by id then use parent resource of scope. So in this example get +// alert by id call will look like this: +// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AlertsManagement/alerts/{alertId}'. +// Parameters: +// alertID - unique ID of an alert instance. +func (client AlertsClient) GetByID(ctx context.Context, alertID string) (result Alert, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.GetByID") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetByIDPreparer(ctx, alertID) + if err != nil { + err = autorest.NewErrorWithError(err, "alertsmanagement.AlertsClient", "GetByID", nil, "Failure preparing request") + return + } + + resp, err := client.GetByIDSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "alertsmanagement.AlertsClient", "GetByID", resp, "Failure sending request") + return + } + + result, err = client.GetByIDResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "alertsmanagement.AlertsClient", "GetByID", resp, "Failure responding to request") + } + + return +} + +// GetByIDPreparer prepares the GetByID request. +func (client AlertsClient) GetByIDPreparer(ctx context.Context, alertID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "alertId": autorest.Encode("path", alertID), + "scope": client.Scope, + } + + const APIVersion = "2018-05-05" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.AlertsManagement/alerts/{alertId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByIDSender sends the GetByID request. The method will close the +// http.Response Body if it receives an error. +func (client AlertsClient) GetByIDSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetByIDResponder handles the response to the GetByID request. The method always +// closes the http.Response Body. +func (client AlertsClient) GetByIDResponder(resp *http.Response) (result Alert, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetHistory get the history of an alert, which captures any monitor condition changes (Fired/Resolved), alert state +// changes (New/Acknowledged/Closed) and applied action rules for that particular alert. If scope is a deleted resource +// then please use scope as parent resource of the delete resource. For example if my alert id is +// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/virtualMachines/vm1/providers/Microsoft.AlertsManagement/alerts/{alertId}' +// and 'vm1' is deleted then if you want to get history of this particular alert then use parent resource of scope. So +// in this example get history call will look like this: +// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AlertsManagement/alerts/{alertId}/history'. +// Parameters: +// alertID - unique ID of an alert instance. +func (client AlertsClient) GetHistory(ctx context.Context, alertID string) (result AlertModification, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.GetHistory") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetHistoryPreparer(ctx, alertID) + if err != nil { + err = autorest.NewErrorWithError(err, "alertsmanagement.AlertsClient", "GetHistory", nil, "Failure preparing request") + return + } + + resp, err := client.GetHistorySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "alertsmanagement.AlertsClient", "GetHistory", resp, "Failure sending request") + return + } + + result, err = client.GetHistoryResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "alertsmanagement.AlertsClient", "GetHistory", resp, "Failure responding to request") + } + + return +} + +// GetHistoryPreparer prepares the GetHistory request. +func (client AlertsClient) GetHistoryPreparer(ctx context.Context, alertID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "alertId": autorest.Encode("path", alertID), + "scope": client.Scope, + } + + const APIVersion = "2018-05-05" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.AlertsManagement/alerts/{alertId}/history", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetHistorySender sends the GetHistory request. The method will close the +// http.Response Body if it receives an error. +func (client AlertsClient) GetHistorySender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetHistoryResponder handles the response to the GetHistory request. The method always +// closes the http.Response Body. +func (client AlertsClient) GetHistoryResponder(resp *http.Response) (result AlertModification, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetSummary get a summarized count of your alerts grouped by various parameters (e.g. grouping by 'Severity' returns +// the count of alerts for each severity). +// Parameters: +// groupby - this parameter allows the result set to be grouped by input fields. For example, +// groupby=severity,alertstate. +// includeSmartGroupsCount - include count of the SmartGroups as part of the summary. Default value is 'false'. +// targetResource - filter by target resource( which is full ARM ID) Default value is select all. +// targetResourceType - filter by target resource type. Default value is select all. +// targetResourceGroup - filter by target resource group name. Default value is select all. +// monitorService - filter by monitor service which generates the alert instance. Default value is select all. +// monitorCondition - filter by monitor condition which is either 'Fired' or 'Resolved'. Default value is to +// select all. +// severity - filter by severity. Default value is select all. +// alertState - filter by state of the alert instance. Default value is to select all. +// alertRule - filter by specific alert rule. Default value is to select all. +// timeRange - filter by time range by below listed values. Default value is 1 day. +// customTimeRange - filter by custom time range in the format / where time is in +// (ISO-8601 format)'. Permissible values is within 30 days from query time. Either timeRange or +// customTimeRange could be used but not both. Default is none. +func (client AlertsClient) GetSummary(ctx context.Context, groupby AlertsSummaryGroupByFields, includeSmartGroupsCount *bool, targetResource string, targetResourceType string, targetResourceGroup string, monitorService MonitorService, monitorCondition MonitorCondition, severity Severity, alertState AlertState, alertRule string, timeRange TimeRange, customTimeRange string) (result AlertsSummary, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.GetSummary") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetSummaryPreparer(ctx, groupby, includeSmartGroupsCount, targetResource, targetResourceType, targetResourceGroup, monitorService, monitorCondition, severity, alertState, alertRule, timeRange, customTimeRange) + if err != nil { + err = autorest.NewErrorWithError(err, "alertsmanagement.AlertsClient", "GetSummary", nil, "Failure preparing request") + return + } + + resp, err := client.GetSummarySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "alertsmanagement.AlertsClient", "GetSummary", resp, "Failure sending request") + return + } + + result, err = client.GetSummaryResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "alertsmanagement.AlertsClient", "GetSummary", resp, "Failure responding to request") + } + + return +} + +// GetSummaryPreparer prepares the GetSummary request. +func (client AlertsClient) GetSummaryPreparer(ctx context.Context, groupby AlertsSummaryGroupByFields, includeSmartGroupsCount *bool, targetResource string, targetResourceType string, targetResourceGroup string, monitorService MonitorService, monitorCondition MonitorCondition, severity Severity, alertState AlertState, alertRule string, timeRange TimeRange, customTimeRange string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scope": client.Scope, + } + + const APIVersion = "2018-05-05" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + "groupby": autorest.Encode("query", groupby), + } + if includeSmartGroupsCount != nil { + queryParameters["includeSmartGroupsCount"] = autorest.Encode("query", *includeSmartGroupsCount) + } + if len(targetResource) > 0 { + queryParameters["targetResource"] = autorest.Encode("query", targetResource) + } + if len(targetResourceType) > 0 { + queryParameters["targetResourceType"] = autorest.Encode("query", targetResourceType) + } + if len(targetResourceGroup) > 0 { + queryParameters["targetResourceGroup"] = autorest.Encode("query", targetResourceGroup) + } + if len(string(monitorService)) > 0 { + queryParameters["monitorService"] = autorest.Encode("query", monitorService) + } + if len(string(monitorCondition)) > 0 { + queryParameters["monitorCondition"] = autorest.Encode("query", monitorCondition) + } + if len(string(severity)) > 0 { + queryParameters["severity"] = autorest.Encode("query", severity) + } + if len(string(alertState)) > 0 { + queryParameters["alertState"] = autorest.Encode("query", alertState) + } + if len(alertRule) > 0 { + queryParameters["alertRule"] = autorest.Encode("query", alertRule) + } + if len(string(timeRange)) > 0 { + queryParameters["timeRange"] = autorest.Encode("query", timeRange) + } + if len(customTimeRange) > 0 { + queryParameters["customTimeRange"] = autorest.Encode("query", customTimeRange) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.AlertsManagement/alertsSummary", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSummarySender sends the GetSummary request. The method will close the +// http.Response Body if it receives an error. +func (client AlertsClient) GetSummarySender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetSummaryResponder handles the response to the GetSummary request. The method always +// closes the http.Response Body. +func (client AlertsClient) GetSummaryResponder(resp *http.Response) (result AlertsSummary, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/alertsmanagementapi/interfaces.go b/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/alertsmanagementapi/interfaces.go new file mode 100644 index 000000000000..606ce4371858 --- /dev/null +++ b/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/alertsmanagementapi/interfaces.go @@ -0,0 +1,63 @@ +package alertsmanagementapi + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement" + "github.com/Azure/go-autorest/autorest" +) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result alertsmanagement.OperationsListPage, err error) +} + +var _ OperationsClientAPI = (*alertsmanagement.OperationsClient)(nil) + +// AlertsClientAPI contains the set of methods on the AlertsClient type. +type AlertsClientAPI interface { + ChangeState(ctx context.Context, alertID string, newState alertsmanagement.AlertState) (result alertsmanagement.Alert, err error) + GetAll(ctx context.Context, targetResource string, targetResourceType string, targetResourceGroup string, monitorService alertsmanagement.MonitorService, monitorCondition alertsmanagement.MonitorCondition, severity alertsmanagement.Severity, alertState alertsmanagement.AlertState, alertRule string, smartGroupID string, includeContext *bool, includeEgressConfig *bool, pageCount *int32, sortBy alertsmanagement.AlertsSortByFields, sortOrder string, selectParameter string, timeRange alertsmanagement.TimeRange, customTimeRange string) (result alertsmanagement.AlertsListPage, err error) + GetByID(ctx context.Context, alertID string) (result alertsmanagement.Alert, err error) + GetHistory(ctx context.Context, alertID string) (result alertsmanagement.AlertModification, err error) + GetSummary(ctx context.Context, groupby alertsmanagement.AlertsSummaryGroupByFields, includeSmartGroupsCount *bool, targetResource string, targetResourceType string, targetResourceGroup string, monitorService alertsmanagement.MonitorService, monitorCondition alertsmanagement.MonitorCondition, severity alertsmanagement.Severity, alertState alertsmanagement.AlertState, alertRule string, timeRange alertsmanagement.TimeRange, customTimeRange string) (result alertsmanagement.AlertsSummary, err error) +} + +var _ AlertsClientAPI = (*alertsmanagement.AlertsClient)(nil) + +// SmartGroupsClientAPI contains the set of methods on the SmartGroupsClient type. +type SmartGroupsClientAPI interface { + ChangeState(ctx context.Context, smartGroupID string, newState alertsmanagement.AlertState) (result alertsmanagement.SmartGroup, err error) + GetAll(ctx context.Context, targetResource string, targetResourceGroup string, targetResourceType string, monitorService alertsmanagement.MonitorService, monitorCondition alertsmanagement.MonitorCondition, severity alertsmanagement.Severity, smartGroupState alertsmanagement.AlertState, timeRange alertsmanagement.TimeRange, pageCount *int32, sortBy alertsmanagement.SmartGroupsSortByFields, sortOrder string) (result alertsmanagement.SmartGroupsList, err error) + GetByID(ctx context.Context, smartGroupID string) (result alertsmanagement.SmartGroup, err error) + GetHistory(ctx context.Context, smartGroupID string) (result alertsmanagement.SmartGroupModification, err error) +} + +var _ SmartGroupsClientAPI = (*alertsmanagement.SmartGroupsClient)(nil) + +// SmartDetectorAlertRulesClientAPI contains the set of methods on the SmartDetectorAlertRulesClient type. +type SmartDetectorAlertRulesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, alertRuleName string, parameters alertsmanagement.AlertRule) (result alertsmanagement.AlertRule, err error) + Delete(ctx context.Context, resourceGroupName string, alertRuleName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, alertRuleName string, expandDetector *bool) (result alertsmanagement.AlertRule, err error) + List(ctx context.Context) (result alertsmanagement.AlertRulesListPage, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result alertsmanagement.AlertRulesListPage, err error) +} + +var _ SmartDetectorAlertRulesClientAPI = (*alertsmanagement.SmartDetectorAlertRulesClient)(nil) diff --git a/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/client.go b/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/client.go new file mode 100644 index 000000000000..6aa6e5818576 --- /dev/null +++ b/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/client.go @@ -0,0 +1,55 @@ +// Package alertsmanagement implements the Azure ARM Alertsmanagement service API version 2019-03-01. +// +// AlertsManagement Client +package alertsmanagement + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Alertsmanagement + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Alertsmanagement. +type BaseClient struct { + autorest.Client + BaseURI string + Scope string + SubscriptionID string + SubscriptionID1 string +} + +// New creates an instance of the BaseClient client. +func New(scope string, subscriptionID string, subscriptionID1 string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, scope, subscriptionID, subscriptionID1) +} + +// NewWithBaseURI creates an instance of the BaseClient client. +func NewWithBaseURI(baseURI string, scope string, subscriptionID string, subscriptionID1 string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + Scope: scope, + SubscriptionID: subscriptionID, + SubscriptionID1: subscriptionID1, + } +} diff --git a/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/models.go b/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/models.go new file mode 100644 index 000000000000..bb713c84ca69 --- /dev/null +++ b/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/models.go @@ -0,0 +1,1249 @@ +package alertsmanagement + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement" + +// AlertModificationEvent enumerates the values for alert modification event. +type AlertModificationEvent string + +const ( + // AlertCreated ... + AlertCreated AlertModificationEvent = "AlertCreated" + // MonitorConditionChange ... + MonitorConditionChange AlertModificationEvent = "MonitorConditionChange" + // StateChange ... + StateChange AlertModificationEvent = "StateChange" +) + +// PossibleAlertModificationEventValues returns an array of possible values for the AlertModificationEvent const type. +func PossibleAlertModificationEventValues() []AlertModificationEvent { + return []AlertModificationEvent{AlertCreated, MonitorConditionChange, StateChange} +} + +// AlertRuleState enumerates the values for alert rule state. +type AlertRuleState string + +const ( + // Disabled ... + Disabled AlertRuleState = "Disabled" + // Enabled ... + Enabled AlertRuleState = "Enabled" +) + +// PossibleAlertRuleStateValues returns an array of possible values for the AlertRuleState const type. +func PossibleAlertRuleStateValues() []AlertRuleState { + return []AlertRuleState{Disabled, Enabled} +} + +// AlertsSortByFields enumerates the values for alerts sort by fields. +type AlertsSortByFields string + +const ( + // AlertsSortByFieldsAlertState ... + AlertsSortByFieldsAlertState AlertsSortByFields = "alertState" + // AlertsSortByFieldsLastModifiedDateTime ... + AlertsSortByFieldsLastModifiedDateTime AlertsSortByFields = "lastModifiedDateTime" + // AlertsSortByFieldsMonitorCondition ... + AlertsSortByFieldsMonitorCondition AlertsSortByFields = "monitorCondition" + // AlertsSortByFieldsName ... + AlertsSortByFieldsName AlertsSortByFields = "name" + // AlertsSortByFieldsSeverity ... + AlertsSortByFieldsSeverity AlertsSortByFields = "severity" + // AlertsSortByFieldsStartDateTime ... + AlertsSortByFieldsStartDateTime AlertsSortByFields = "startDateTime" + // AlertsSortByFieldsTargetResource ... + AlertsSortByFieldsTargetResource AlertsSortByFields = "targetResource" + // AlertsSortByFieldsTargetResourceGroup ... + AlertsSortByFieldsTargetResourceGroup AlertsSortByFields = "targetResourceGroup" + // AlertsSortByFieldsTargetResourceName ... + AlertsSortByFieldsTargetResourceName AlertsSortByFields = "targetResourceName" + // AlertsSortByFieldsTargetResourceType ... + AlertsSortByFieldsTargetResourceType AlertsSortByFields = "targetResourceType" +) + +// PossibleAlertsSortByFieldsValues returns an array of possible values for the AlertsSortByFields const type. +func PossibleAlertsSortByFieldsValues() []AlertsSortByFields { + return []AlertsSortByFields{AlertsSortByFieldsAlertState, AlertsSortByFieldsLastModifiedDateTime, AlertsSortByFieldsMonitorCondition, AlertsSortByFieldsName, AlertsSortByFieldsSeverity, AlertsSortByFieldsStartDateTime, AlertsSortByFieldsTargetResource, AlertsSortByFieldsTargetResourceGroup, AlertsSortByFieldsTargetResourceName, AlertsSortByFieldsTargetResourceType} +} + +// AlertsSummaryGroupByFields enumerates the values for alerts summary group by fields. +type AlertsSummaryGroupByFields string + +const ( + // AlertsSummaryGroupByFieldsAlertRule ... + AlertsSummaryGroupByFieldsAlertRule AlertsSummaryGroupByFields = "alertRule" + // AlertsSummaryGroupByFieldsAlertState ... + AlertsSummaryGroupByFieldsAlertState AlertsSummaryGroupByFields = "alertState" + // AlertsSummaryGroupByFieldsMonitorCondition ... + AlertsSummaryGroupByFieldsMonitorCondition AlertsSummaryGroupByFields = "monitorCondition" + // AlertsSummaryGroupByFieldsMonitorService ... + AlertsSummaryGroupByFieldsMonitorService AlertsSummaryGroupByFields = "monitorService" + // AlertsSummaryGroupByFieldsSeverity ... + AlertsSummaryGroupByFieldsSeverity AlertsSummaryGroupByFields = "severity" + // AlertsSummaryGroupByFieldsSignalType ... + AlertsSummaryGroupByFieldsSignalType AlertsSummaryGroupByFields = "signalType" +) + +// PossibleAlertsSummaryGroupByFieldsValues returns an array of possible values for the AlertsSummaryGroupByFields const type. +func PossibleAlertsSummaryGroupByFieldsValues() []AlertsSummaryGroupByFields { + return []AlertsSummaryGroupByFields{AlertsSummaryGroupByFieldsAlertRule, AlertsSummaryGroupByFieldsAlertState, AlertsSummaryGroupByFieldsMonitorCondition, AlertsSummaryGroupByFieldsMonitorService, AlertsSummaryGroupByFieldsSeverity, AlertsSummaryGroupByFieldsSignalType} +} + +// AlertState enumerates the values for alert state. +type AlertState string + +const ( + // AlertStateAcknowledged ... + AlertStateAcknowledged AlertState = "Acknowledged" + // AlertStateClosed ... + AlertStateClosed AlertState = "Closed" + // AlertStateNew ... + AlertStateNew AlertState = "New" +) + +// PossibleAlertStateValues returns an array of possible values for the AlertState const type. +func PossibleAlertStateValues() []AlertState { + return []AlertState{AlertStateAcknowledged, AlertStateClosed, AlertStateNew} +} + +// MonitorCondition enumerates the values for monitor condition. +type MonitorCondition string + +const ( + // Fired ... + Fired MonitorCondition = "Fired" + // Resolved ... + Resolved MonitorCondition = "Resolved" +) + +// PossibleMonitorConditionValues returns an array of possible values for the MonitorCondition const type. +func PossibleMonitorConditionValues() []MonitorCondition { + return []MonitorCondition{Fired, Resolved} +} + +// MonitorService enumerates the values for monitor service. +type MonitorService string + +const ( + // ActivityLogAdministrative ... + ActivityLogAdministrative MonitorService = "ActivityLog Administrative" + // ActivityLogAutoscale ... + ActivityLogAutoscale MonitorService = "ActivityLog Autoscale" + // ActivityLogPolicy ... + ActivityLogPolicy MonitorService = "ActivityLog Policy" + // ActivityLogRecommendation ... + ActivityLogRecommendation MonitorService = "ActivityLog Recommendation" + // ActivityLogSecurity ... + ActivityLogSecurity MonitorService = "ActivityLog Security" + // ApplicationInsights ... + ApplicationInsights MonitorService = "Application Insights" + // LogAnalytics ... + LogAnalytics MonitorService = "Log Analytics" + // Nagios ... + Nagios MonitorService = "Nagios" + // Platform ... + Platform MonitorService = "Platform" + // ResourceHealth ... + ResourceHealth MonitorService = "Resource Health" + // SCOM ... + SCOM MonitorService = "SCOM" + // ServiceHealth ... + ServiceHealth MonitorService = "ServiceHealth" + // SmartDetector ... + SmartDetector MonitorService = "SmartDetector" + // VMInsights ... + VMInsights MonitorService = "VM Insights" + // Zabbix ... + Zabbix MonitorService = "Zabbix" +) + +// PossibleMonitorServiceValues returns an array of possible values for the MonitorService const type. +func PossibleMonitorServiceValues() []MonitorService { + return []MonitorService{ActivityLogAdministrative, ActivityLogAutoscale, ActivityLogPolicy, ActivityLogRecommendation, ActivityLogSecurity, ApplicationInsights, LogAnalytics, Nagios, Platform, ResourceHealth, SCOM, ServiceHealth, SmartDetector, VMInsights, Zabbix} +} + +// Severity enumerates the values for severity. +type Severity string + +const ( + // Sev0 ... + Sev0 Severity = "Sev0" + // Sev1 ... + Sev1 Severity = "Sev1" + // Sev2 ... + Sev2 Severity = "Sev2" + // Sev3 ... + Sev3 Severity = "Sev3" + // Sev4 ... + Sev4 Severity = "Sev4" +) + +// PossibleSeverityValues returns an array of possible values for the Severity const type. +func PossibleSeverityValues() []Severity { + return []Severity{Sev0, Sev1, Sev2, Sev3, Sev4} +} + +// SignalType enumerates the values for signal type. +type SignalType string + +const ( + // Log ... + Log SignalType = "Log" + // Metric ... + Metric SignalType = "Metric" + // Unknown ... + Unknown SignalType = "Unknown" +) + +// PossibleSignalTypeValues returns an array of possible values for the SignalType const type. +func PossibleSignalTypeValues() []SignalType { + return []SignalType{Log, Metric, Unknown} +} + +// SmartGroupModificationEvent enumerates the values for smart group modification event. +type SmartGroupModificationEvent string + +const ( + // SmartGroupModificationEventAlertAdded ... + SmartGroupModificationEventAlertAdded SmartGroupModificationEvent = "AlertAdded" + // SmartGroupModificationEventAlertRemoved ... + SmartGroupModificationEventAlertRemoved SmartGroupModificationEvent = "AlertRemoved" + // SmartGroupModificationEventSmartGroupCreated ... + SmartGroupModificationEventSmartGroupCreated SmartGroupModificationEvent = "SmartGroupCreated" + // SmartGroupModificationEventStateChange ... + SmartGroupModificationEventStateChange SmartGroupModificationEvent = "StateChange" +) + +// PossibleSmartGroupModificationEventValues returns an array of possible values for the SmartGroupModificationEvent const type. +func PossibleSmartGroupModificationEventValues() []SmartGroupModificationEvent { + return []SmartGroupModificationEvent{SmartGroupModificationEventAlertAdded, SmartGroupModificationEventAlertRemoved, SmartGroupModificationEventSmartGroupCreated, SmartGroupModificationEventStateChange} +} + +// SmartGroupsSortByFields enumerates the values for smart groups sort by fields. +type SmartGroupsSortByFields string + +const ( + // SmartGroupsSortByFieldsAlertsCount ... + SmartGroupsSortByFieldsAlertsCount SmartGroupsSortByFields = "alertsCount" + // SmartGroupsSortByFieldsLastModifiedDateTime ... + SmartGroupsSortByFieldsLastModifiedDateTime SmartGroupsSortByFields = "lastModifiedDateTime" + // SmartGroupsSortByFieldsSeverity ... + SmartGroupsSortByFieldsSeverity SmartGroupsSortByFields = "severity" + // SmartGroupsSortByFieldsStartDateTime ... + SmartGroupsSortByFieldsStartDateTime SmartGroupsSortByFields = "startDateTime" + // SmartGroupsSortByFieldsState ... + SmartGroupsSortByFieldsState SmartGroupsSortByFields = "state" +) + +// PossibleSmartGroupsSortByFieldsValues returns an array of possible values for the SmartGroupsSortByFields const type. +func PossibleSmartGroupsSortByFieldsValues() []SmartGroupsSortByFields { + return []SmartGroupsSortByFields{SmartGroupsSortByFieldsAlertsCount, SmartGroupsSortByFieldsLastModifiedDateTime, SmartGroupsSortByFieldsSeverity, SmartGroupsSortByFieldsStartDateTime, SmartGroupsSortByFieldsState} +} + +// State enumerates the values for state. +type State string + +const ( + // StateAcknowledged ... + StateAcknowledged State = "Acknowledged" + // StateClosed ... + StateClosed State = "Closed" + // StateNew ... + StateNew State = "New" +) + +// PossibleStateValues returns an array of possible values for the State const type. +func PossibleStateValues() []State { + return []State{StateAcknowledged, StateClosed, StateNew} +} + +// TimeRange enumerates the values for time range. +type TimeRange string + +const ( + // Oned ... + Oned TimeRange = "1d" + // Oneh ... + Oneh TimeRange = "1h" + // Sevend ... + Sevend TimeRange = "7d" + // ThreeZerod ... + ThreeZerod TimeRange = "30d" +) + +// PossibleTimeRangeValues returns an array of possible values for the TimeRange const type. +func PossibleTimeRangeValues() []TimeRange { + return []TimeRange{Oned, Oneh, Sevend, ThreeZerod} +} + +// ActionGroupsInformation the Action Groups information, used by the alert rule. +type ActionGroupsInformation struct { + // CustomEmailSubject - An optional custom email subject to use in email notifications. + CustomEmailSubject *string `json:"customEmailSubject,omitempty"` + // CustomWebhookPayload - An optional custom web-hook payload to use in web-hook notifications. + CustomWebhookPayload *string `json:"customWebhookPayload,omitempty"` + // GroupIds - The Action Group resource IDs. + GroupIds *[]string `json:"groupIds,omitempty"` +} + +// Alert an alert created in alert management service. +type Alert struct { + autorest.Response `json:"-"` + Properties *AlertProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` +} + +// AlertModification alert Modification details +type AlertModification struct { + autorest.Response `json:"-"` + Properties *AlertModificationProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` +} + +// AlertModificationItem alert modification item. +type AlertModificationItem struct { + // ModificationEvent - Reason for the modification. Possible values include: 'AlertCreated', 'StateChange', 'MonitorConditionChange' + ModificationEvent AlertModificationEvent `json:"modificationEvent,omitempty"` + // OldValue - Old value + OldValue *string `json:"oldValue,omitempty"` + // NewValue - New value + NewValue *string `json:"newValue,omitempty"` + // ModifiedAt - Modified date and time + ModifiedAt *string `json:"modifiedAt,omitempty"` + // ModifiedBy - Modified user details (Principal client name) + ModifiedBy *string `json:"modifiedBy,omitempty"` + // Comments - Modification comments + Comments *string `json:"comments,omitempty"` + // Description - Description of the modification + Description *string `json:"description,omitempty"` +} + +// AlertModificationProperties properties of the alert modification item. +type AlertModificationProperties struct { + // AlertID - READ-ONLY; Unique Id of the alert for which the history is being retrieved + AlertID *string `json:"alertId,omitempty"` + // Modifications - Modification details + Modifications *[]AlertModificationItem `json:"modifications,omitempty"` +} + +// AlertProperties alert property bag +type AlertProperties struct { + Essentials *Essentials `json:"essentials,omitempty"` + Context interface{} `json:"context,omitempty"` + EgressConfig interface{} `json:"egressConfig,omitempty"` +} + +// AlertRule the alert rule information +type AlertRule struct { + autorest.Response `json:"-"` + // AlertRuleProperties - The properties of the alert rule. + *AlertRuleProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The resource ID. + ID *string `json:"id,omitempty"` + // Type - READ-ONLY; The resource type. + Type *string `json:"type,omitempty"` + // Name - READ-ONLY; The resource name. + Name *string `json:"name,omitempty"` +} + +// MarshalJSON is the custom marshaler for AlertRule. +func (ar AlertRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ar.AlertRuleProperties != nil { + objectMap["properties"] = ar.AlertRuleProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AlertRule struct. +func (ar *AlertRule) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var alertRuleProperties AlertRuleProperties + err = json.Unmarshal(*v, &alertRuleProperties) + if err != nil { + return err + } + ar.AlertRuleProperties = &alertRuleProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ar.ID = &ID + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ar.Type = &typeVar + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ar.Name = &name + } + } + } + + return nil +} + +// AlertRuleProperties the alert rule properties. +type AlertRuleProperties struct { + // Description - The alert rule description. + Description *string `json:"description,omitempty"` + // State - The alert rule state. Possible values include: 'Enabled', 'Disabled' + State AlertRuleState `json:"state,omitempty"` + // Severity - The alert rule severity. Possible values include: 'Sev0', 'Sev1', 'Sev2', 'Sev3', 'Sev4' + Severity Severity `json:"severity,omitempty"` + // Frequency - The alert rule frequency in ISO8601 format. The time granularity must be in minutes and minimum value is 5 minutes. + Frequency *string `json:"frequency,omitempty"` + // Detector - The alert rule's detector. + Detector *Detector `json:"detector,omitempty"` + // Scope - The alert rule resources scope. + Scope *[]string `json:"scope,omitempty"` + // ActionGroups - The alert rule actions. + ActionGroups *ActionGroupsInformation `json:"actionGroups,omitempty"` + // Throttling - The alert rule throttling information. + Throttling *ThrottlingInformation `json:"throttling,omitempty"` +} + +// AlertRulesList list of Smart Detector alert rules. +type AlertRulesList struct { + autorest.Response `json:"-"` + // Value - List of Smart Detector alert rules. + Value *[]AlertRule `json:"value,omitempty"` + // NextLink - The URL to get the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// AlertRulesListIterator provides access to a complete listing of AlertRule values. +type AlertRulesListIterator struct { + i int + page AlertRulesListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *AlertRulesListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertRulesListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *AlertRulesListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter AlertRulesListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter AlertRulesListIterator) Response() AlertRulesList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter AlertRulesListIterator) Value() AlertRule { + if !iter.page.NotDone() { + return AlertRule{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the AlertRulesListIterator type. +func NewAlertRulesListIterator(page AlertRulesListPage) AlertRulesListIterator { + return AlertRulesListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (arl AlertRulesList) IsEmpty() bool { + return arl.Value == nil || len(*arl.Value) == 0 +} + +// alertRulesListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (arl AlertRulesList) alertRulesListPreparer(ctx context.Context) (*http.Request, error) { + if arl.NextLink == nil || len(to.String(arl.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(arl.NextLink))) +} + +// AlertRulesListPage contains a page of AlertRule values. +type AlertRulesListPage struct { + fn func(context.Context, AlertRulesList) (AlertRulesList, error) + arl AlertRulesList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *AlertRulesListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertRulesListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.arl) + if err != nil { + return err + } + page.arl = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *AlertRulesListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page AlertRulesListPage) NotDone() bool { + return !page.arl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page AlertRulesListPage) Response() AlertRulesList { + return page.arl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page AlertRulesListPage) Values() []AlertRule { + if page.arl.IsEmpty() { + return nil + } + return *page.arl.Value +} + +// Creates a new instance of the AlertRulesListPage type. +func NewAlertRulesListPage(getNextPage func(context.Context, AlertRulesList) (AlertRulesList, error)) AlertRulesListPage { + return AlertRulesListPage{fn: getNextPage} +} + +// AlertsList list the alerts. +type AlertsList struct { + autorest.Response `json:"-"` + // NextLink - URL to fetch the next set of alerts. + NextLink *string `json:"nextLink,omitempty"` + // Value - List of alerts + Value *[]Alert `json:"value,omitempty"` +} + +// AlertsListIterator provides access to a complete listing of Alert values. +type AlertsListIterator struct { + i int + page AlertsListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *AlertsListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *AlertsListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter AlertsListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter AlertsListIterator) Response() AlertsList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter AlertsListIterator) Value() Alert { + if !iter.page.NotDone() { + return Alert{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the AlertsListIterator type. +func NewAlertsListIterator(page AlertsListPage) AlertsListIterator { + return AlertsListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (al AlertsList) IsEmpty() bool { + return al.Value == nil || len(*al.Value) == 0 +} + +// alertsListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (al AlertsList) alertsListPreparer(ctx context.Context) (*http.Request, error) { + if al.NextLink == nil || len(to.String(al.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(al.NextLink))) +} + +// AlertsListPage contains a page of Alert values. +type AlertsListPage struct { + fn func(context.Context, AlertsList) (AlertsList, error) + al AlertsList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *AlertsListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.al) + if err != nil { + return err + } + page.al = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *AlertsListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page AlertsListPage) NotDone() bool { + return !page.al.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page AlertsListPage) Response() AlertsList { + return page.al +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page AlertsListPage) Values() []Alert { + if page.al.IsEmpty() { + return nil + } + return *page.al.Value +} + +// Creates a new instance of the AlertsListPage type. +func NewAlertsListPage(getNextPage func(context.Context, AlertsList) (AlertsList, error)) AlertsListPage { + return AlertsListPage{fn: getNextPage} +} + +// AlertsSummary summary of alerts based on the input filters and 'groupby' parameters. +type AlertsSummary struct { + autorest.Response `json:"-"` + Properties *AlertsSummaryGroup `json:"properties,omitempty"` + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` +} + +// AlertsSummaryGroup group the result set. +type AlertsSummaryGroup struct { + // Total - Total count of the result set. + Total *int32 `json:"total,omitempty"` + // SmartGroupsCount - Total count of the smart groups. + SmartGroupsCount *int32 `json:"smartGroupsCount,omitempty"` + // Groupedby - Name of the field aggregated + Groupedby *string `json:"groupedby,omitempty"` + // Values - List of the items + Values *[]AlertsSummaryGroupItem `json:"values,omitempty"` +} + +// AlertsSummaryGroupItem alerts summary group item +type AlertsSummaryGroupItem struct { + // Name - Value of the aggregated field + Name *string `json:"name,omitempty"` + // Count - Count of the aggregated field + Count *int32 `json:"count,omitempty"` + // Groupedby - Name of the field aggregated + Groupedby *string `json:"groupedby,omitempty"` + // Values - List of the items + Values *[]AlertsSummaryGroupItem `json:"values,omitempty"` +} + +// AzureResource an Azure resource object +type AzureResource struct { + // ID - READ-ONLY; The resource ID. + ID *string `json:"id,omitempty"` + // Type - READ-ONLY; The resource type. + Type *string `json:"type,omitempty"` + // Name - READ-ONLY; The resource name. + Name *string `json:"name,omitempty"` +} + +// Detector the detector information. By default this is not populated, unless it's specified in +// expandDetector +type Detector struct { + // ID - The detector id. + ID *string `json:"id,omitempty"` + // Parameters - The detector's parameters.' + Parameters map[string]interface{} `json:"parameters"` + // Name - The Smart Detector name. By default this is not populated, unless it's specified in expandDetector + Name *string `json:"name,omitempty"` + // Description - The Smart Detector description. By default this is not populated, unless it's specified in expandDetector + Description *string `json:"description,omitempty"` + // SupportedResourceTypes - The Smart Detector supported resource types. By default this is not populated, unless it's specified in expandDetector + SupportedResourceTypes *[]string `json:"supportedResourceTypes,omitempty"` + // ImagePaths - The Smart Detector image path. By default this is not populated, unless it's specified in expandDetector + ImagePaths *[]string `json:"imagePaths,omitempty"` +} + +// MarshalJSON is the custom marshaler for Detector. +func (d Detector) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if d.ID != nil { + objectMap["id"] = d.ID + } + if d.Parameters != nil { + objectMap["parameters"] = d.Parameters + } + if d.Name != nil { + objectMap["name"] = d.Name + } + if d.Description != nil { + objectMap["description"] = d.Description + } + if d.SupportedResourceTypes != nil { + objectMap["supportedResourceTypes"] = d.SupportedResourceTypes + } + if d.ImagePaths != nil { + objectMap["imagePaths"] = d.ImagePaths + } + return json.Marshal(objectMap) +} + +// ErrorResponse an error response from the service. +type ErrorResponse struct { + Error *ErrorResponseBody `json:"error,omitempty"` +} + +// ErrorResponse1 describe the format of an Error response. +type ErrorResponse1 struct { + // Code - Error code + Code *string `json:"code,omitempty"` + // Message - Error message indicating why the operation failed. + Message *string `json:"message,omitempty"` +} + +// ErrorResponseBody details of error response. +type ErrorResponseBody struct { + // Code - Error code, intended to be consumed programmatically. + Code *string `json:"code,omitempty"` + // Message - Description of the error, intended for display in user interface. + Message *string `json:"message,omitempty"` + // Target - Target of the particular error, for example name of the property. + Target *string `json:"target,omitempty"` + // Details - A list of additional details about the error. + Details *[]ErrorResponseBody `json:"details,omitempty"` +} + +// Essentials this object contains consistent fields across different monitor services. +type Essentials struct { + // Severity - READ-ONLY; Severity of alert Sev0 being highest and Sev4 being lowest. Possible values include: 'Sev0', 'Sev1', 'Sev2', 'Sev3', 'Sev4' + Severity Severity `json:"severity,omitempty"` + // SignalType - READ-ONLY; The type of signal the alert is based on, which could be metrics, logs or activity logs. Possible values include: 'Metric', 'Log', 'Unknown' + SignalType SignalType `json:"signalType,omitempty"` + // AlertState - READ-ONLY; Alert object state, which can be modified by the user. Possible values include: 'AlertStateNew', 'AlertStateAcknowledged', 'AlertStateClosed' + AlertState AlertState `json:"alertState,omitempty"` + // MonitorCondition - READ-ONLY; Can be 'Fired' or 'Resolved', which represents whether the underlying conditions have crossed the defined alert rule thresholds. Possible values include: 'Fired', 'Resolved' + MonitorCondition MonitorCondition `json:"monitorCondition,omitempty"` + // TargetResource - Target ARM resource, on which alert got created. + TargetResource *string `json:"targetResource,omitempty"` + // TargetResourceName - Name of the target ARM resource name, on which alert got created. + TargetResourceName *string `json:"targetResourceName,omitempty"` + // TargetResourceGroup - Resource group of target ARM resource, on which alert got created. + TargetResourceGroup *string `json:"targetResourceGroup,omitempty"` + // TargetResourceType - Resource type of target ARM resource, on which alert got created. + TargetResourceType *string `json:"targetResourceType,omitempty"` + // MonitorService - READ-ONLY; Monitor service on which the rule(monitor) is set. Possible values include: 'ApplicationInsights', 'ActivityLogAdministrative', 'ActivityLogSecurity', 'ActivityLogRecommendation', 'ActivityLogPolicy', 'ActivityLogAutoscale', 'LogAnalytics', 'Nagios', 'Platform', 'SCOM', 'ServiceHealth', 'SmartDetector', 'VMInsights', 'Zabbix', 'ResourceHealth' + MonitorService MonitorService `json:"monitorService,omitempty"` + // AlertRule - READ-ONLY; Rule(monitor) which fired alert instance. Depending on the monitor service, this would be ARM id or name of the rule. + AlertRule *string `json:"alertRule,omitempty"` + // SourceCreatedID - READ-ONLY; Unique Id created by monitor service for each alert instance. This could be used to track the issue at the monitor service, in case of Nagios, Zabbix, SCOM etc. + SourceCreatedID *string `json:"sourceCreatedId,omitempty"` + // SmartGroupID - READ-ONLY; Unique Id of the smart group + SmartGroupID *string `json:"smartGroupId,omitempty"` + // SmartGroupingReason - READ-ONLY; Verbose reason describing the reason why this alert instance is added to a smart group + SmartGroupingReason *string `json:"smartGroupingReason,omitempty"` + // StartDateTime - READ-ONLY; Creation time(ISO-8601 format) of alert instance. + StartDateTime *date.Time `json:"startDateTime,omitempty"` + // LastModifiedDateTime - READ-ONLY; Last modification time(ISO-8601 format) of alert instance. + LastModifiedDateTime *date.Time `json:"lastModifiedDateTime,omitempty"` + // MonitorConditionResolvedDateTime - READ-ONLY; Resolved time(ISO-8601 format) of alert instance. This will be updated when monitor service resolves the alert instance because the rule condition is no longer met. + MonitorConditionResolvedDateTime *date.Time `json:"monitorConditionResolvedDateTime,omitempty"` + // LastModifiedUserName - READ-ONLY; User who last modified the alert, in case of monitor service updates user would be 'system', otherwise name of the user. + LastModifiedUserName *string `json:"lastModifiedUserName,omitempty"` +} + +// Operation operation provided by provider +type Operation struct { + // Name - Name of the operation + Name *string `json:"name,omitempty"` + // Display - Properties of the operation + Display *OperationDisplay `json:"display,omitempty"` +} + +// OperationDisplay properties of the operation +type OperationDisplay struct { + // Provider - Provider name + Provider *string `json:"provider,omitempty"` + // Resource - Resource name + Resource *string `json:"resource,omitempty"` + // Operation - Operation name + Operation *string `json:"operation,omitempty"` + // Description - Description of the operation + Description *string `json:"description,omitempty"` +} + +// OperationsList lists the operations available in the AlertsManagement RP. +type OperationsList struct { + autorest.Response `json:"-"` + // NextLink - URL to fetch the next set of alerts. + NextLink *string `json:"nextLink,omitempty"` + // Value - Array of operations + Value *[]Operation `json:"value,omitempty"` +} + +// OperationsListIterator provides access to a complete listing of Operation values. +type OperationsListIterator struct { + i int + page OperationsListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OperationsListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *OperationsListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationsListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter OperationsListIterator) Response() OperationsList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter OperationsListIterator) Value() Operation { + if !iter.page.NotDone() { + return Operation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationsListIterator type. +func NewOperationsListIterator(page OperationsListPage) OperationsListIterator { + return OperationsListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ol OperationsList) IsEmpty() bool { + return ol.Value == nil || len(*ol.Value) == 0 +} + +// operationsListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ol OperationsList) operationsListPreparer(ctx context.Context) (*http.Request, error) { + if ol.NextLink == nil || len(to.String(ol.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ol.NextLink))) +} + +// OperationsListPage contains a page of Operation values. +type OperationsListPage struct { + fn func(context.Context, OperationsList) (OperationsList, error) + ol OperationsList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OperationsListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.ol) + if err != nil { + return err + } + page.ol = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *OperationsListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationsListPage) NotDone() bool { + return !page.ol.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationsListPage) Response() OperationsList { + return page.ol +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationsListPage) Values() []Operation { + if page.ol.IsEmpty() { + return nil + } + return *page.ol.Value +} + +// Creates a new instance of the OperationsListPage type. +func NewOperationsListPage(getNextPage func(context.Context, OperationsList) (OperationsList, error)) OperationsListPage { + return OperationsListPage{fn: getNextPage} +} + +// ProxyResource an azure resource object +type ProxyResource struct { + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` +} + +// SmartGroup set of related alerts grouped together smartly by AMS. +type SmartGroup struct { + autorest.Response `json:"-"` + *SmartGroupProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` +} + +// MarshalJSON is the custom marshaler for SmartGroup. +func (sg SmartGroup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sg.SmartGroupProperties != nil { + objectMap["properties"] = sg.SmartGroupProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SmartGroup struct. +func (sg *SmartGroup) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var smartGroupProperties SmartGroupProperties + err = json.Unmarshal(*v, &smartGroupProperties) + if err != nil { + return err + } + sg.SmartGroupProperties = &smartGroupProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sg.ID = &ID + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sg.Type = &typeVar + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sg.Name = &name + } + } + } + + return nil +} + +// SmartGroupAggregatedProperty aggregated property of each type +type SmartGroupAggregatedProperty struct { + // Name - Name of the type. + Name *string `json:"name,omitempty"` + // Count - Total number of items of type. + Count *int32 `json:"count,omitempty"` +} + +// SmartGroupModification alert Modification details +type SmartGroupModification struct { + autorest.Response `json:"-"` + Properties *SmartGroupModificationProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` +} + +// SmartGroupModificationItem smartGroup modification item. +type SmartGroupModificationItem struct { + // ModificationEvent - Reason for the modification. Possible values include: 'SmartGroupModificationEventSmartGroupCreated', 'SmartGroupModificationEventStateChange', 'SmartGroupModificationEventAlertAdded', 'SmartGroupModificationEventAlertRemoved' + ModificationEvent SmartGroupModificationEvent `json:"modificationEvent,omitempty"` + // OldValue - Old value + OldValue *string `json:"oldValue,omitempty"` + // NewValue - New value + NewValue *string `json:"newValue,omitempty"` + // ModifiedAt - Modified date and time + ModifiedAt *string `json:"modifiedAt,omitempty"` + // ModifiedBy - Modified user details (Principal client name) + ModifiedBy *string `json:"modifiedBy,omitempty"` + // Comments - Modification comments + Comments *string `json:"comments,omitempty"` + // Description - Description of the modification + Description *string `json:"description,omitempty"` +} + +// SmartGroupModificationProperties properties of the smartGroup modification item. +type SmartGroupModificationProperties struct { + // SmartGroupID - READ-ONLY; Unique Id of the smartGroup for which the history is being retrieved + SmartGroupID *string `json:"smartGroupId,omitempty"` + // Modifications - Modification details + Modifications *[]SmartGroupModificationItem `json:"modifications,omitempty"` + // NextLink - URL to fetch the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// SmartGroupProperties properties of smart group. +type SmartGroupProperties struct { + // AlertsCount - Total number of alerts in smart group + AlertsCount *int32 `json:"alertsCount,omitempty"` + // SmartGroupState - READ-ONLY; Smart group state. Possible values include: 'StateNew', 'StateAcknowledged', 'StateClosed' + SmartGroupState State `json:"smartGroupState,omitempty"` + // Severity - READ-ONLY; Severity of smart group is the highest(Sev0 >... > Sev4) severity of all the alerts in the group. Possible values include: 'Sev0', 'Sev1', 'Sev2', 'Sev3', 'Sev4' + Severity Severity `json:"severity,omitempty"` + // StartDateTime - READ-ONLY; Creation time of smart group. Date-Time in ISO-8601 format. + StartDateTime *date.Time `json:"startDateTime,omitempty"` + // LastModifiedDateTime - READ-ONLY; Last updated time of smart group. Date-Time in ISO-8601 format. + LastModifiedDateTime *date.Time `json:"lastModifiedDateTime,omitempty"` + // LastModifiedUserName - READ-ONLY; Last modified by user name. + LastModifiedUserName *string `json:"lastModifiedUserName,omitempty"` + // Resources - Summary of target resources in the smart group + Resources *[]SmartGroupAggregatedProperty `json:"resources,omitempty"` + // ResourceTypes - Summary of target resource types in the smart group + ResourceTypes *[]SmartGroupAggregatedProperty `json:"resourceTypes,omitempty"` + // ResourceGroups - Summary of target resource groups in the smart group + ResourceGroups *[]SmartGroupAggregatedProperty `json:"resourceGroups,omitempty"` + // MonitorServices - Summary of monitorServices in the smart group + MonitorServices *[]SmartGroupAggregatedProperty `json:"monitorServices,omitempty"` + // MonitorConditions - Summary of monitorConditions in the smart group + MonitorConditions *[]SmartGroupAggregatedProperty `json:"monitorConditions,omitempty"` + // AlertStates - Summary of alertStates in the smart group + AlertStates *[]SmartGroupAggregatedProperty `json:"alertStates,omitempty"` + // AlertSeverities - Summary of alertSeverities in the smart group + AlertSeverities *[]SmartGroupAggregatedProperty `json:"alertSeverities,omitempty"` + // NextLink - The URI to fetch the next page of alerts. Call ListNext() with this URI to fetch the next page alerts. + NextLink *string `json:"nextLink,omitempty"` +} + +// SmartGroupsList list the alerts. +type SmartGroupsList struct { + autorest.Response `json:"-"` + // NextLink - URL to fetch the next set of alerts. + NextLink *string `json:"nextLink,omitempty"` + // Value - List of alerts + Value *[]SmartGroup `json:"value,omitempty"` +} + +// ThrottlingInformation optional throttling information for the alert rule. +type ThrottlingInformation struct { + // Duration - The required duration (in ISO8601 format) to wait before notifying on the alert rule again. The time granularity must be in minutes and minimum value is 0 minutes + Duration *string `json:"duration,omitempty"` +} diff --git a/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/operations.go b/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/operations.go new file mode 100644 index 000000000000..19113860ebb5 --- /dev/null +++ b/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/operations.go @@ -0,0 +1,147 @@ +package alertsmanagement + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationsClient is the alertsManagement Client +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(scope string, subscriptionID string, subscriptionID1 string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, scope, subscriptionID, subscriptionID1) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client. +func NewOperationsClientWithBaseURI(baseURI string, scope string, subscriptionID string, subscriptionID1 string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, scope, subscriptionID, subscriptionID1)} +} + +// List list all operations available through Azure Alerts Management Resource Provider. +func (client OperationsClient) List(ctx context.Context) (result OperationsListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.ol.Response.Response != nil { + sc = result.ol.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "alertsmanagement.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.ol.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "alertsmanagement.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.ol, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "alertsmanagement.OperationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2018-05-05" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.AlertsManagement/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationsList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OperationsClient) listNextResults(ctx context.Context, lastResults OperationsList) (result OperationsList, err error) { + req, err := lastResults.operationsListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "alertsmanagement.OperationsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "alertsmanagement.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "alertsmanagement.OperationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationsClient) ListComplete(ctx context.Context) (result OperationsListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} diff --git a/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/smartdetectoralertrules.go b/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/smartdetectoralertrules.go new file mode 100644 index 000000000000..4f16fb82d3d0 --- /dev/null +++ b/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/smartdetectoralertrules.go @@ -0,0 +1,515 @@ +package alertsmanagement + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// SmartDetectorAlertRulesClient is the alertsManagement Client +type SmartDetectorAlertRulesClient struct { + BaseClient +} + +// NewSmartDetectorAlertRulesClient creates an instance of the SmartDetectorAlertRulesClient client. +func NewSmartDetectorAlertRulesClient(scope string, subscriptionID string, subscriptionID1 string) SmartDetectorAlertRulesClient { + return NewSmartDetectorAlertRulesClientWithBaseURI(DefaultBaseURI, scope, subscriptionID, subscriptionID1) +} + +// NewSmartDetectorAlertRulesClientWithBaseURI creates an instance of the SmartDetectorAlertRulesClient client. +func NewSmartDetectorAlertRulesClientWithBaseURI(baseURI string, scope string, subscriptionID string, subscriptionID1 string) SmartDetectorAlertRulesClient { + return SmartDetectorAlertRulesClient{NewWithBaseURI(baseURI, scope, subscriptionID, subscriptionID1)} +} + +// CreateOrUpdate create or update a Smart Detector alert rule. +// Parameters: +// resourceGroupName - the name of the resource group. +// alertRuleName - the name of the alert rule. +// parameters - parameters supplied to the operation. +func (client SmartDetectorAlertRulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, alertRuleName string, parameters AlertRule) (result AlertRule, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SmartDetectorAlertRulesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.AlertRuleProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.AlertRuleProperties.Frequency", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.AlertRuleProperties.Detector", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.AlertRuleProperties.Detector.ID", Name: validation.Null, Rule: true, Chain: nil}}}, + {Target: "parameters.AlertRuleProperties.Scope", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.AlertRuleProperties.ActionGroups", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.AlertRuleProperties.ActionGroups.GroupIds", Name: validation.Null, Rule: true, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("alertsmanagement.SmartDetectorAlertRulesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, alertRuleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "alertsmanagement.SmartDetectorAlertRulesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "alertsmanagement.SmartDetectorAlertRulesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "alertsmanagement.SmartDetectorAlertRulesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client SmartDetectorAlertRulesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, alertRuleName string, parameters AlertRule) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "alertRuleName": autorest.Encode("path", alertRuleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.alertsManagement/smartDetectorAlertRules/{alertRuleName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client SmartDetectorAlertRulesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client SmartDetectorAlertRulesClient) CreateOrUpdateResponder(resp *http.Response) (result AlertRule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete an existing Smart Detector alert rule. +// Parameters: +// resourceGroupName - the name of the resource group. +// alertRuleName - the name of the alert rule. +func (client SmartDetectorAlertRulesClient) Delete(ctx context.Context, resourceGroupName string, alertRuleName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SmartDetectorAlertRulesClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, alertRuleName) + if err != nil { + err = autorest.NewErrorWithError(err, "alertsmanagement.SmartDetectorAlertRulesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "alertsmanagement.SmartDetectorAlertRulesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "alertsmanagement.SmartDetectorAlertRulesClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client SmartDetectorAlertRulesClient) DeletePreparer(ctx context.Context, resourceGroupName string, alertRuleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "alertRuleName": autorest.Encode("path", alertRuleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.alertsManagement/smartDetectorAlertRules/{alertRuleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client SmartDetectorAlertRulesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client SmartDetectorAlertRulesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get a specific Smart Detector alert rule. +// Parameters: +// resourceGroupName - the name of the resource group. +// alertRuleName - the name of the alert rule. +// expandDetector - indicates if Smart Detector should be expanded. +func (client SmartDetectorAlertRulesClient) Get(ctx context.Context, resourceGroupName string, alertRuleName string, expandDetector *bool) (result AlertRule, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SmartDetectorAlertRulesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, alertRuleName, expandDetector) + if err != nil { + err = autorest.NewErrorWithError(err, "alertsmanagement.SmartDetectorAlertRulesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "alertsmanagement.SmartDetectorAlertRulesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "alertsmanagement.SmartDetectorAlertRulesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client SmartDetectorAlertRulesClient) GetPreparer(ctx context.Context, resourceGroupName string, alertRuleName string, expandDetector *bool) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "alertRuleName": autorest.Encode("path", alertRuleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if expandDetector != nil { + queryParameters["expandDetector"] = autorest.Encode("query", *expandDetector) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.alertsManagement/smartDetectorAlertRules/{alertRuleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client SmartDetectorAlertRulesClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SmartDetectorAlertRulesClient) GetResponder(resp *http.Response) (result AlertRule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list all the existing Smart Detector alert rules within the subscription. +func (client SmartDetectorAlertRulesClient) List(ctx context.Context) (result AlertRulesListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SmartDetectorAlertRulesClient.List") + defer func() { + sc := -1 + if result.arl.Response.Response != nil { + sc = result.arl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "alertsmanagement.SmartDetectorAlertRulesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.arl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "alertsmanagement.SmartDetectorAlertRulesClient", "List", resp, "Failure sending request") + return + } + + result.arl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "alertsmanagement.SmartDetectorAlertRulesClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client SmartDetectorAlertRulesClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/microsoft.alertsManagement/smartDetectorAlertRules", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client SmartDetectorAlertRulesClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client SmartDetectorAlertRulesClient) ListResponder(resp *http.Response) (result AlertRulesList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client SmartDetectorAlertRulesClient) listNextResults(ctx context.Context, lastResults AlertRulesList) (result AlertRulesList, err error) { + req, err := lastResults.alertRulesListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "alertsmanagement.SmartDetectorAlertRulesClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "alertsmanagement.SmartDetectorAlertRulesClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "alertsmanagement.SmartDetectorAlertRulesClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client SmartDetectorAlertRulesClient) ListComplete(ctx context.Context) (result AlertRulesListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SmartDetectorAlertRulesClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} + +// ListByResourceGroup list all the existing Smart Detector alert rules within the subscription and resource group. +// Parameters: +// resourceGroupName - the name of the resource group. +func (client SmartDetectorAlertRulesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result AlertRulesListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SmartDetectorAlertRulesClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.arl.Response.Response != nil { + sc = result.arl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "alertsmanagement.SmartDetectorAlertRulesClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.arl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "alertsmanagement.SmartDetectorAlertRulesClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.arl, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "alertsmanagement.SmartDetectorAlertRulesClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client SmartDetectorAlertRulesClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.alertsManagement/smartDetectorAlertRules", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client SmartDetectorAlertRulesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client SmartDetectorAlertRulesClient) ListByResourceGroupResponder(resp *http.Response) (result AlertRulesList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client SmartDetectorAlertRulesClient) listByResourceGroupNextResults(ctx context.Context, lastResults AlertRulesList) (result AlertRulesList, err error) { + req, err := lastResults.alertRulesListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "alertsmanagement.SmartDetectorAlertRulesClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "alertsmanagement.SmartDetectorAlertRulesClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "alertsmanagement.SmartDetectorAlertRulesClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client SmartDetectorAlertRulesClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result AlertRulesListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SmartDetectorAlertRulesClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} diff --git a/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/smartgroups.go b/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/smartgroups.go new file mode 100644 index 000000000000..378ad63557c0 --- /dev/null +++ b/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/smartgroups.go @@ -0,0 +1,388 @@ +package alertsmanagement + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// SmartGroupsClient is the alertsManagement Client +type SmartGroupsClient struct { + BaseClient +} + +// NewSmartGroupsClient creates an instance of the SmartGroupsClient client. +func NewSmartGroupsClient(scope string, subscriptionID string, subscriptionID1 string) SmartGroupsClient { + return NewSmartGroupsClientWithBaseURI(DefaultBaseURI, scope, subscriptionID, subscriptionID1) +} + +// NewSmartGroupsClientWithBaseURI creates an instance of the SmartGroupsClient client. +func NewSmartGroupsClientWithBaseURI(baseURI string, scope string, subscriptionID string, subscriptionID1 string) SmartGroupsClient { + return SmartGroupsClient{NewWithBaseURI(baseURI, scope, subscriptionID, subscriptionID1)} +} + +// ChangeState change the state of a Smart Group. +// Parameters: +// smartGroupID - smart group unique id. +// newState - new state of the alert. +func (client SmartGroupsClient) ChangeState(ctx context.Context, smartGroupID string, newState AlertState) (result SmartGroup, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SmartGroupsClient.ChangeState") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ChangeStatePreparer(ctx, smartGroupID, newState) + if err != nil { + err = autorest.NewErrorWithError(err, "alertsmanagement.SmartGroupsClient", "ChangeState", nil, "Failure preparing request") + return + } + + resp, err := client.ChangeStateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "alertsmanagement.SmartGroupsClient", "ChangeState", resp, "Failure sending request") + return + } + + result, err = client.ChangeStateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "alertsmanagement.SmartGroupsClient", "ChangeState", resp, "Failure responding to request") + } + + return +} + +// ChangeStatePreparer prepares the ChangeState request. +func (client SmartGroupsClient) ChangeStatePreparer(ctx context.Context, smartGroupID string, newState AlertState) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "smartGroupId": autorest.Encode("path", smartGroupID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-05-05" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + "newState": autorest.Encode("query", newState), + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/smartGroups/{smartGroupId}/changeState", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ChangeStateSender sends the ChangeState request. The method will close the +// http.Response Body if it receives an error. +func (client SmartGroupsClient) ChangeStateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ChangeStateResponder handles the response to the ChangeState request. The method always +// closes the http.Response Body. +func (client SmartGroupsClient) ChangeStateResponder(resp *http.Response) (result SmartGroup, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetAll list all the Smart Groups within a specified subscription. +// Parameters: +// targetResource - filter by target resource( which is full ARM ID) Default value is select all. +// targetResourceGroup - filter by target resource group name. Default value is select all. +// targetResourceType - filter by target resource type. Default value is select all. +// monitorService - filter by monitor service which generates the alert instance. Default value is select all. +// monitorCondition - filter by monitor condition which is either 'Fired' or 'Resolved'. Default value is to +// select all. +// severity - filter by severity. Default value is select all. +// smartGroupState - filter by state of the smart group. Default value is to select all. +// timeRange - filter by time range by below listed values. Default value is 1 day. +// pageCount - determines number of alerts returned per page in response. Permissible value is between 1 to +// 250. When the "includeContent" filter is selected, maximum value allowed is 25. Default value is 25. +// sortBy - sort the query results by input field. Default value is sort by 'lastModifiedDateTime'. +// sortOrder - sort the query results order in either ascending or descending. Default value is 'desc' for +// time fields and 'asc' for others. +func (client SmartGroupsClient) GetAll(ctx context.Context, targetResource string, targetResourceGroup string, targetResourceType string, monitorService MonitorService, monitorCondition MonitorCondition, severity Severity, smartGroupState AlertState, timeRange TimeRange, pageCount *int32, sortBy SmartGroupsSortByFields, sortOrder string) (result SmartGroupsList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SmartGroupsClient.GetAll") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetAllPreparer(ctx, targetResource, targetResourceGroup, targetResourceType, monitorService, monitorCondition, severity, smartGroupState, timeRange, pageCount, sortBy, sortOrder) + if err != nil { + err = autorest.NewErrorWithError(err, "alertsmanagement.SmartGroupsClient", "GetAll", nil, "Failure preparing request") + return + } + + resp, err := client.GetAllSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "alertsmanagement.SmartGroupsClient", "GetAll", resp, "Failure sending request") + return + } + + result, err = client.GetAllResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "alertsmanagement.SmartGroupsClient", "GetAll", resp, "Failure responding to request") + } + + return +} + +// GetAllPreparer prepares the GetAll request. +func (client SmartGroupsClient) GetAllPreparer(ctx context.Context, targetResource string, targetResourceGroup string, targetResourceType string, monitorService MonitorService, monitorCondition MonitorCondition, severity Severity, smartGroupState AlertState, timeRange TimeRange, pageCount *int32, sortBy SmartGroupsSortByFields, sortOrder string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-05-05" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(targetResource) > 0 { + queryParameters["targetResource"] = autorest.Encode("query", targetResource) + } + if len(targetResourceGroup) > 0 { + queryParameters["targetResourceGroup"] = autorest.Encode("query", targetResourceGroup) + } + if len(targetResourceType) > 0 { + queryParameters["targetResourceType"] = autorest.Encode("query", targetResourceType) + } + if len(string(monitorService)) > 0 { + queryParameters["monitorService"] = autorest.Encode("query", monitorService) + } + if len(string(monitorCondition)) > 0 { + queryParameters["monitorCondition"] = autorest.Encode("query", monitorCondition) + } + if len(string(severity)) > 0 { + queryParameters["severity"] = autorest.Encode("query", severity) + } + if len(string(smartGroupState)) > 0 { + queryParameters["smartGroupState"] = autorest.Encode("query", smartGroupState) + } + if len(string(timeRange)) > 0 { + queryParameters["timeRange"] = autorest.Encode("query", timeRange) + } + if pageCount != nil { + queryParameters["pageCount"] = autorest.Encode("query", *pageCount) + } + if len(string(sortBy)) > 0 { + queryParameters["sortBy"] = autorest.Encode("query", sortBy) + } + if len(string(sortOrder)) > 0 { + queryParameters["sortOrder"] = autorest.Encode("query", sortOrder) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/smartGroups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetAllSender sends the GetAll request. The method will close the +// http.Response Body if it receives an error. +func (client SmartGroupsClient) GetAllSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetAllResponder handles the response to the GetAll request. The method always +// closes the http.Response Body. +func (client SmartGroupsClient) GetAllResponder(resp *http.Response) (result SmartGroupsList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetByID get information related to a specific Smart Group. +// Parameters: +// smartGroupID - smart group unique id. +func (client SmartGroupsClient) GetByID(ctx context.Context, smartGroupID string) (result SmartGroup, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SmartGroupsClient.GetByID") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetByIDPreparer(ctx, smartGroupID) + if err != nil { + err = autorest.NewErrorWithError(err, "alertsmanagement.SmartGroupsClient", "GetByID", nil, "Failure preparing request") + return + } + + resp, err := client.GetByIDSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "alertsmanagement.SmartGroupsClient", "GetByID", resp, "Failure sending request") + return + } + + result, err = client.GetByIDResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "alertsmanagement.SmartGroupsClient", "GetByID", resp, "Failure responding to request") + } + + return +} + +// GetByIDPreparer prepares the GetByID request. +func (client SmartGroupsClient) GetByIDPreparer(ctx context.Context, smartGroupID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "smartGroupId": autorest.Encode("path", smartGroupID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-05-05" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/smartGroups/{smartGroupId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByIDSender sends the GetByID request. The method will close the +// http.Response Body if it receives an error. +func (client SmartGroupsClient) GetByIDSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetByIDResponder handles the response to the GetByID request. The method always +// closes the http.Response Body. +func (client SmartGroupsClient) GetByIDResponder(resp *http.Response) (result SmartGroup, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetHistory get the history a smart group, which captures any Smart Group state changes (New/Acknowledged/Closed) . +// Parameters: +// smartGroupID - smart group unique id. +func (client SmartGroupsClient) GetHistory(ctx context.Context, smartGroupID string) (result SmartGroupModification, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SmartGroupsClient.GetHistory") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetHistoryPreparer(ctx, smartGroupID) + if err != nil { + err = autorest.NewErrorWithError(err, "alertsmanagement.SmartGroupsClient", "GetHistory", nil, "Failure preparing request") + return + } + + resp, err := client.GetHistorySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "alertsmanagement.SmartGroupsClient", "GetHistory", resp, "Failure sending request") + return + } + + result, err = client.GetHistoryResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "alertsmanagement.SmartGroupsClient", "GetHistory", resp, "Failure responding to request") + } + + return +} + +// GetHistoryPreparer prepares the GetHistory request. +func (client SmartGroupsClient) GetHistoryPreparer(ctx context.Context, smartGroupID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "smartGroupId": autorest.Encode("path", smartGroupID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-05-05" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/smartGroups/{smartGroupId}/history", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetHistorySender sends the GetHistory request. The method will close the +// http.Response Body if it receives an error. +func (client SmartGroupsClient) GetHistorySender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetHistoryResponder handles the response to the GetHistory request. The method always +// closes the http.Response Body. +func (client SmartGroupsClient) GetHistoryResponder(resp *http.Response) (result SmartGroupModification, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/version.go b/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/version.go new file mode 100644 index 000000000000..f2fd9aebf59a --- /dev/null +++ b/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/version.go @@ -0,0 +1,30 @@ +package alertsmanagement + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + version.Number + " alertsmanagement/2019-03-01" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} diff --git a/services/preview/alertsmanagement/mgmt/2018-05-05-preview/alertsmanagement/alertsmanagementapi/interfaces.go b/services/preview/alertsmanagement/mgmt/2018-05-05-preview/alertsmanagement/alertsmanagementapi/interfaces.go new file mode 100644 index 000000000000..5b6e7af938d7 --- /dev/null +++ b/services/preview/alertsmanagement/mgmt/2018-05-05-preview/alertsmanagement/alertsmanagementapi/interfaces.go @@ -0,0 +1,51 @@ +package alertsmanagementapi + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/preview/alertsmanagement/mgmt/2018-05-05-preview/alertsmanagement" +) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result alertsmanagement.OperationsListPage, err error) +} + +var _ OperationsClientAPI = (*alertsmanagement.OperationsClient)(nil) + +// AlertsClientAPI contains the set of methods on the AlertsClient type. +type AlertsClientAPI interface { + ChangeState(ctx context.Context, alertID string, newState alertsmanagement.AlertState) (result alertsmanagement.Alert, err error) + GetAll(ctx context.Context, targetResource string, targetResourceGroup string, targetResourceType string, monitorCondition alertsmanagement.MonitorCondition, severity alertsmanagement.Severity, alertState alertsmanagement.AlertState, smartGroupID string, includePayload *bool, pageCount *int32, sortBy alertsmanagement.AlertsSortByFields, sortOrder string, timeRange alertsmanagement.TimeRange) (result alertsmanagement.AlertsListPage, err error) + GetByID(ctx context.Context, alertID string) (result alertsmanagement.Alert, err error) + GetHistory(ctx context.Context, alertID string) (result alertsmanagement.AlertModification, err error) + GetSummary(ctx context.Context, targetResourceGroup string, timeRange alertsmanagement.TimeRange) (result alertsmanagement.AlertsSummary, err error) +} + +var _ AlertsClientAPI = (*alertsmanagement.AlertsClient)(nil) + +// SmartGroupsClientAPI contains the set of methods on the SmartGroupsClient type. +type SmartGroupsClientAPI interface { + ChangeState(ctx context.Context, smartGroupID string, newState alertsmanagement.AlertState) (result alertsmanagement.SmartGroup, err error) + GetAll(ctx context.Context, targetResource string, targetResourceGroup string, targetResourceType string, monitorCondition alertsmanagement.MonitorCondition, severity alertsmanagement.Severity, smartGroupState alertsmanagement.AlertState, timeRange alertsmanagement.TimeRange, pageCount *int32, sortBy alertsmanagement.SmartGroupsSortByFields, sortOrder string) (result alertsmanagement.SmartGroupsList, err error) + GetByID(ctx context.Context, smartGroupID string) (result alertsmanagement.SmartGroup, err error) + GetHistory(ctx context.Context, smartGroupID string) (result alertsmanagement.SmartGroupModification, err error) +} + +var _ SmartGroupsClientAPI = (*alertsmanagement.SmartGroupsClient)(nil) diff --git a/services/preview/alertsmanagement/mgmt/2018-05-05-preview/alertsmanagement/client.go b/services/preview/alertsmanagement/mgmt/2018-05-05-preview/alertsmanagement/client.go index 26a30b57e88f..baebc81b0b26 100644 --- a/services/preview/alertsmanagement/mgmt/2018-05-05-preview/alertsmanagement/client.go +++ b/services/preview/alertsmanagement/mgmt/2018-05-05-preview/alertsmanagement/client.go @@ -26,7 +26,7 @@ import ( const ( // DefaultBaseURI is the default URI used for the service Alertsmanagement - DefaultBaseURI = "" + DefaultBaseURI = "https://management.azure.com" ) // BaseClient is the base client for Alertsmanagement. diff --git a/services/preview/alertsmanagement/mgmt/2018-05-05-preview/alertsmanagement/models.go b/services/preview/alertsmanagement/mgmt/2018-05-05-preview/alertsmanagement/models.go index 6490e4f3e80a..ae001699bfc7 100644 --- a/services/preview/alertsmanagement/mgmt/2018-05-05-preview/alertsmanagement/models.go +++ b/services/preview/alertsmanagement/mgmt/2018-05-05-preview/alertsmanagement/models.go @@ -282,11 +282,11 @@ func PossibleTimeRangeValues() []TimeRange { type Alert struct { autorest.Response `json:"-"` *AlertProperties `json:"properties,omitempty"` - // ID - Azure resource Id + // ID - READ-ONLY; Azure resource Id ID *string `json:"id,omitempty"` - // Type - Azure resource type + // Type - READ-ONLY; Azure resource type Type *string `json:"type,omitempty"` - // Name - Azure resource name + // Name - READ-ONLY; Azure resource name Name *string `json:"name,omitempty"` } @@ -296,15 +296,6 @@ func (a Alert) MarshalJSON() ([]byte, error) { if a.AlertProperties != nil { objectMap["properties"] = a.AlertProperties } - if a.ID != nil { - objectMap["id"] = a.ID - } - if a.Type != nil { - objectMap["type"] = a.Type - } - if a.Name != nil { - objectMap["name"] = a.Name - } return json.Marshal(objectMap) } @@ -363,11 +354,11 @@ func (a *Alert) UnmarshalJSON(body []byte) error { type AlertModification struct { autorest.Response `json:"-"` Properties *AlertModificationProperties `json:"properties,omitempty"` - // ID - Azure resource Id + // ID - READ-ONLY; Azure resource Id ID *string `json:"id,omitempty"` - // Type - Azure resource type + // Type - READ-ONLY; Azure resource type Type *string `json:"type,omitempty"` - // Name - Azure resource name + // Name - READ-ONLY; Azure resource name Name *string `json:"name,omitempty"` } @@ -391,7 +382,7 @@ type AlertModificationItem struct { // AlertModificationProperties properties of the alert modification item. type AlertModificationProperties struct { - // AlertID - Unique Id of the alert for which the history is being retrieved + // AlertID - READ-ONLY; Unique Id of the alert for which the history is being retrieved AlertID *string `json:"alertId,omitempty"` // Modifications - Modification details Modifications *[]AlertModificationItem `json:"modifications,omitempty"` @@ -399,13 +390,13 @@ type AlertModificationProperties struct { // AlertProperties an alert created in alert management service. type AlertProperties struct { - // Severity - Severity of alert Sev1 being highest and Sev3 being lowest. Possible values include: 'Sev0', 'Sev1', 'Sev2', 'Sev3', 'Sev4' + // Severity - READ-ONLY; Severity of alert Sev1 being highest and Sev3 being lowest. Possible values include: 'Sev0', 'Sev1', 'Sev2', 'Sev3', 'Sev4' Severity Severity `json:"severity,omitempty"` - // SignalType - Log based alert or metric based alert. Possible values include: 'Metric', 'Log', 'Unknown' + // SignalType - READ-ONLY; Log based alert or metric based alert. Possible values include: 'Metric', 'Log', 'Unknown' SignalType SignalType `json:"signalType,omitempty"` - // AlertState - Alert object state. Possible values include: 'AlertStateNew', 'AlertStateAcknowledged', 'AlertStateClosed' + // AlertState - READ-ONLY; Alert object state. Possible values include: 'AlertStateNew', 'AlertStateAcknowledged', 'AlertStateClosed' AlertState AlertState `json:"alertState,omitempty"` - // MonitorCondition - Condition of the rule at the monitor service. Possible values include: 'Fired', 'Resolved' + // MonitorCondition - READ-ONLY; Condition of the rule at the monitor service. Possible values include: 'Fired', 'Resolved' MonitorCondition MonitorCondition `json:"monitorCondition,omitempty"` // TargetResource - Target ARM resource, on which alert got created. TargetResource *string `json:"targetResource,omitempty"` @@ -415,21 +406,21 @@ type AlertProperties struct { TargetResourceGroup *string `json:"targetResourceGroup,omitempty"` // TargetResourceType - Resource type of target ARM resource TargetResourceType *string `json:"targetResourceType,omitempty"` - // MonitorService - Monitor service which is the source of the alert object. Possible values include: 'Platform', 'ApplicationInsights', 'LogAnalytics', 'InfrastructureInsights', 'ActivityLogAdministrative', 'ActivityLogSecurity', 'ActivityLogRecommendation', 'ActivityLogPolicy', 'ActivityLogAutoscale', 'ServiceHealth', 'SmartDetector', 'Zabbix', 'SCOM', 'Nagios' + // MonitorService - READ-ONLY; Monitor service which is the source of the alert object. Possible values include: 'Platform', 'ApplicationInsights', 'LogAnalytics', 'InfrastructureInsights', 'ActivityLogAdministrative', 'ActivityLogSecurity', 'ActivityLogRecommendation', 'ActivityLogPolicy', 'ActivityLogAutoscale', 'ServiceHealth', 'SmartDetector', 'Zabbix', 'SCOM', 'Nagios' MonitorService MonitorService `json:"monitorService,omitempty"` - // SourceCreatedID - Unique Id created by monitor service + // SourceCreatedID - READ-ONLY; Unique Id created by monitor service SourceCreatedID *string `json:"sourceCreatedId,omitempty"` - // SmartGroupID - Unique Id of the smart group + // SmartGroupID - READ-ONLY; Unique Id of the smart group SmartGroupID *string `json:"smartGroupId,omitempty"` - // SmartGroupingReason - Reason for addition to a smart group + // SmartGroupingReason - READ-ONLY; Reason for addition to a smart group SmartGroupingReason *string `json:"smartGroupingReason,omitempty"` - // StartDateTime - Creation time(ISO-8601 format). + // StartDateTime - READ-ONLY; Creation time(ISO-8601 format). StartDateTime *date.Time `json:"startDateTime,omitempty"` - // LastModifiedDateTime - Last modification time(ISO-8601 format). + // LastModifiedDateTime - READ-ONLY; Last modification time(ISO-8601 format). LastModifiedDateTime *date.Time `json:"lastModifiedDateTime,omitempty"` - // LastModifiedUserName - User who last modified the alert. + // LastModifiedUserName - READ-ONLY; User who last modified the alert. LastModifiedUserName *string `json:"lastModifiedUserName,omitempty"` - // Payload - More details which are contextual to the monitor service. + // Payload - READ-ONLY; More details which are contextual to the monitor service. Payload interface{} `json:"payload,omitempty"` } @@ -500,6 +491,11 @@ func (iter AlertsListIterator) Value() Alert { return iter.page.Values()[iter.i] } +// Creates a new instance of the AlertsListIterator type. +func NewAlertsListIterator(page AlertsListPage) AlertsListIterator { + return AlertsListIterator{page: page} +} + // IsEmpty returns true if the ListResult contains no values. func (al AlertsList) IsEmpty() bool { return al.Value == nil || len(*al.Value) == 0 @@ -569,15 +565,20 @@ func (page AlertsListPage) Values() []Alert { return *page.al.Value } +// Creates a new instance of the AlertsListPage type. +func NewAlertsListPage(getNextPage func(context.Context, AlertsList) (AlertsList, error)) AlertsListPage { + return AlertsListPage{fn: getNextPage} +} + // AlertsSummary summary of the alerts. type AlertsSummary struct { autorest.Response `json:"-"` *AlertsSummaryProperties `json:"properties,omitempty"` - // ID - Azure resource Id + // ID - READ-ONLY; Azure resource Id ID *string `json:"id,omitempty"` - // Type - Azure resource type + // Type - READ-ONLY; Azure resource type Type *string `json:"type,omitempty"` - // Name - Azure resource name + // Name - READ-ONLY; Azure resource name Name *string `json:"name,omitempty"` } @@ -587,15 +588,6 @@ func (as AlertsSummary) MarshalJSON() ([]byte, error) { if as.AlertsSummaryProperties != nil { objectMap["properties"] = as.AlertsSummaryProperties } - if as.ID != nil { - objectMap["id"] = as.ID - } - if as.Type != nil { - objectMap["type"] = as.Type - } - if as.Name != nil { - objectMap["name"] = as.Name - } return json.Marshal(objectMap) } @@ -1002,6 +994,11 @@ func (iter OperationsListIterator) Value() Operation { return iter.page.Values()[iter.i] } +// Creates a new instance of the OperationsListIterator type. +func NewOperationsListIterator(page OperationsListPage) OperationsListIterator { + return OperationsListIterator{page: page} +} + // IsEmpty returns true if the ListResult contains no values. func (ol OperationsList) IsEmpty() bool { return ol.Value == nil || len(*ol.Value) == 0 @@ -1071,13 +1068,18 @@ func (page OperationsListPage) Values() []Operation { return *page.ol.Value } +// Creates a new instance of the OperationsListPage type. +func NewOperationsListPage(getNextPage func(context.Context, OperationsList) (OperationsList, error)) OperationsListPage { + return OperationsListPage{fn: getNextPage} +} + // Resource an azure resource object type Resource struct { - // ID - Azure resource Id + // ID - READ-ONLY; Azure resource Id ID *string `json:"id,omitempty"` - // Type - Azure resource type + // Type - READ-ONLY; Azure resource type Type *string `json:"type,omitempty"` - // Name - Azure resource name + // Name - READ-ONLY; Azure resource name Name *string `json:"name,omitempty"` } @@ -1085,11 +1087,11 @@ type Resource struct { type SmartGroup struct { autorest.Response `json:"-"` *SmartGroupProperties `json:"properties,omitempty"` - // ID - Azure resource Id + // ID - READ-ONLY; Azure resource Id ID *string `json:"id,omitempty"` - // Type - Azure resource type + // Type - READ-ONLY; Azure resource type Type *string `json:"type,omitempty"` - // Name - Azure resource name + // Name - READ-ONLY; Azure resource name Name *string `json:"name,omitempty"` } @@ -1099,15 +1101,6 @@ func (sg SmartGroup) MarshalJSON() ([]byte, error) { if sg.SmartGroupProperties != nil { objectMap["properties"] = sg.SmartGroupProperties } - if sg.ID != nil { - objectMap["id"] = sg.ID - } - if sg.Type != nil { - objectMap["type"] = sg.Type - } - if sg.Name != nil { - objectMap["name"] = sg.Name - } return json.Marshal(objectMap) } @@ -1174,11 +1167,11 @@ type SmartGroupAggregatedProperty struct { type SmartGroupModification struct { autorest.Response `json:"-"` Properties *SmartGroupModificationProperties `json:"properties,omitempty"` - // ID - Azure resource Id + // ID - READ-ONLY; Azure resource Id ID *string `json:"id,omitempty"` - // Type - Azure resource type + // Type - READ-ONLY; Azure resource type Type *string `json:"type,omitempty"` - // Name - Azure resource name + // Name - READ-ONLY; Azure resource name Name *string `json:"name,omitempty"` } @@ -1202,7 +1195,7 @@ type SmartGroupModificationItem struct { // SmartGroupModificationProperties properties of the smartGroup modification item. type SmartGroupModificationProperties struct { - // SmartGroupID - Unique Id of the smartGroup for which the history is being retrieved + // SmartGroupID - READ-ONLY; Unique Id of the smartGroup for which the history is being retrieved SmartGroupID *string `json:"smartGroupId,omitempty"` // Modifications - Modification details Modifications *[]SmartGroupModificationItem `json:"modifications,omitempty"` @@ -1214,15 +1207,15 @@ type SmartGroupModificationProperties struct { type SmartGroupProperties struct { // AlertsCount - Total number of alerts in smart group AlertsCount *int32 `json:"alertsCount,omitempty"` - // SmartGroupState - Smart group state. Possible values include: 'StateNew', 'StateAcknowledged', 'StateClosed' + // SmartGroupState - READ-ONLY; Smart group state. Possible values include: 'StateNew', 'StateAcknowledged', 'StateClosed' SmartGroupState State `json:"smartGroupState,omitempty"` - // Severity - Severity of smart group is the highest(Sev0 >... > Sev4) severity of all the alerts in the group. Possible values include: 'Sev0', 'Sev1', 'Sev2', 'Sev3', 'Sev4' + // Severity - READ-ONLY; Severity of smart group is the highest(Sev0 >... > Sev4) severity of all the alerts in the group. Possible values include: 'Sev0', 'Sev1', 'Sev2', 'Sev3', 'Sev4' Severity Severity `json:"severity,omitempty"` - // StartDateTime - Creation time of smart group. Date-Time in ISO-8601 format. + // StartDateTime - READ-ONLY; Creation time of smart group. Date-Time in ISO-8601 format. StartDateTime *date.Time `json:"startDateTime,omitempty"` - // LastModifiedDateTime - Last updated time of smart group. Date-Time in ISO-8601 format. + // LastModifiedDateTime - READ-ONLY; Last updated time of smart group. Date-Time in ISO-8601 format. LastModifiedDateTime *date.Time `json:"lastModifiedDateTime,omitempty"` - // LastModifiedUserName - Last modified by user name. + // LastModifiedUserName - READ-ONLY; Last modified by user name. LastModifiedUserName *string `json:"lastModifiedUserName,omitempty"` // Resources - Summary of target resources in the smart group Resources *[]SmartGroupAggregatedProperty `json:"resources,omitempty"` diff --git a/services/preview/alertsmanagement/mgmt/2019-05-05/alertsmanagement/alerts.go b/services/preview/alertsmanagement/mgmt/2019-05-05/alertsmanagement/alerts.go index cdc469399c25..b61dfab4b030 100644 --- a/services/preview/alertsmanagement/mgmt/2019-05-05/alertsmanagement/alerts.go +++ b/services/preview/alertsmanagement/mgmt/2019-05-05/alertsmanagement/alerts.go @@ -580,3 +580,72 @@ func (client AlertsClient) GetSummaryResponder(resp *http.Response) (result Aler result.Response = autorest.Response{Response: resp} return } + +// MetaData list alerts meta data information based on value of identifier parameter. +func (client AlertsClient) MetaData(ctx context.Context) (result AlertsMetaData, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.MetaData") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.MetaDataPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "alertsmanagement.AlertsClient", "MetaData", nil, "Failure preparing request") + return + } + + resp, err := client.MetaDataSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "alertsmanagement.AlertsClient", "MetaData", resp, "Failure sending request") + return + } + + result, err = client.MetaDataResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "alertsmanagement.AlertsClient", "MetaData", resp, "Failure responding to request") + } + + return +} + +// MetaDataPreparer prepares the MetaData request. +func (client AlertsClient) MetaDataPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2019-05-05-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + "identifier": autorest.Encode("query", "MonitorServiceList"), + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.AlertsManagement/alertsMetaData"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// MetaDataSender sends the MetaData request. The method will close the +// http.Response Body if it receives an error. +func (client AlertsClient) MetaDataSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// MetaDataResponder handles the response to the MetaData request. The method always +// closes the http.Response Body. +func (client AlertsClient) MetaDataResponder(resp *http.Response) (result AlertsMetaData, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/alertsmanagement/mgmt/2019-05-05/alertsmanagement/alertsmanagementapi/interfaces.go b/services/preview/alertsmanagement/mgmt/2019-05-05/alertsmanagement/alertsmanagementapi/interfaces.go index faaf5395b80f..d2d90ae31f3c 100644 --- a/services/preview/alertsmanagement/mgmt/2019-05-05/alertsmanagement/alertsmanagementapi/interfaces.go +++ b/services/preview/alertsmanagement/mgmt/2019-05-05/alertsmanagement/alertsmanagementapi/interfaces.go @@ -36,6 +36,7 @@ type AlertsClientAPI interface { GetByID(ctx context.Context, alertID string) (result alertsmanagement.Alert, err error) GetHistory(ctx context.Context, alertID string) (result alertsmanagement.AlertModification, err error) GetSummary(ctx context.Context, groupby alertsmanagement.AlertsSummaryGroupByFields, includeSmartGroupsCount *bool, targetResource string, targetResourceType string, targetResourceGroup string, monitorService alertsmanagement.MonitorService, monitorCondition alertsmanagement.MonitorCondition, severity alertsmanagement.Severity, alertState alertsmanagement.AlertState, alertRule string, timeRange alertsmanagement.TimeRange, customTimeRange string) (result alertsmanagement.AlertsSummary, err error) + MetaData(ctx context.Context) (result alertsmanagement.AlertsMetaData, err error) } var _ AlertsClientAPI = (*alertsmanagement.AlertsClient)(nil) diff --git a/services/preview/alertsmanagement/mgmt/2019-05-05/alertsmanagement/client.go b/services/preview/alertsmanagement/mgmt/2019-05-05/alertsmanagement/client.go index 497ccddd5807..c8a30b18418b 100644 --- a/services/preview/alertsmanagement/mgmt/2019-05-05/alertsmanagement/client.go +++ b/services/preview/alertsmanagement/mgmt/2019-05-05/alertsmanagement/client.go @@ -27,6 +27,8 @@ import ( const ( // DefaultBaseURI is the default URI used for the service Alertsmanagement DefaultBaseURI = "https://management.azure.com" + // DefaultIdentifier is the default value for identifier + DefaultIdentifier = "MonitorServiceList" ) // BaseClient is the base client for Alertsmanagement. @@ -34,6 +36,7 @@ type BaseClient struct { autorest.Client BaseURI string SubscriptionID string + Identifier string } // New creates an instance of the BaseClient client. @@ -47,5 +50,6 @@ func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { Client: autorest.NewClientWithUserAgent(UserAgent()), BaseURI: baseURI, SubscriptionID: subscriptionID, + Identifier: DefaultIdentifier, } } diff --git a/services/preview/alertsmanagement/mgmt/2019-05-05/alertsmanagement/models.go b/services/preview/alertsmanagement/mgmt/2019-05-05/alertsmanagement/models.go index 9bfe3b9e0f7c..cb42cbdb47fa 100644 --- a/services/preview/alertsmanagement/mgmt/2019-05-05/alertsmanagement/models.go +++ b/services/preview/alertsmanagement/mgmt/2019-05-05/alertsmanagement/models.go @@ -133,6 +133,21 @@ func PossibleAlertStateValues() []AlertState { return []AlertState{AlertStateAcknowledged, AlertStateClosed, AlertStateNew} } +// MetadataIdentifier enumerates the values for metadata identifier. +type MetadataIdentifier string + +const ( + // MetadataIdentifierAlertsMetaDataProperties ... + MetadataIdentifierAlertsMetaDataProperties MetadataIdentifier = "alertsMetaDataProperties" + // MetadataIdentifierMonitorServiceList ... + MetadataIdentifierMonitorServiceList MetadataIdentifier = "MonitorServiceList" +) + +// PossibleMetadataIdentifierValues returns an array of possible values for the MetadataIdentifier const type. +func PossibleMetadataIdentifierValues() []MetadataIdentifier { + return []MetadataIdentifier{MetadataIdentifierAlertsMetaDataProperties, MetadataIdentifierMonitorServiceList} +} + // MonitorCondition enumerates the values for monitor condition. type MonitorCondition string @@ -1018,6 +1033,109 @@ func NewAlertsListPage(getNextPage func(context.Context, AlertsList) (AlertsList return AlertsListPage{fn: getNextPage} } +// AlertsMetaData alert meta data information. +type AlertsMetaData struct { + autorest.Response `json:"-"` + Properties BasicAlertsMetaDataProperties `json:"properties,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for AlertsMetaData struct. +func (amd *AlertsMetaData) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + properties, err := unmarshalBasicAlertsMetaDataProperties(*v) + if err != nil { + return err + } + amd.Properties = properties + } + } + } + + return nil +} + +// BasicAlertsMetaDataProperties alert meta data property bag +type BasicAlertsMetaDataProperties interface { + AsMonitorServiceList() (*MonitorServiceList, bool) + AsAlertsMetaDataProperties() (*AlertsMetaDataProperties, bool) +} + +// AlertsMetaDataProperties alert meta data property bag +type AlertsMetaDataProperties struct { + // MetadataIdentifier - Possible values include: 'MetadataIdentifierAlertsMetaDataProperties', 'MetadataIdentifierMonitorServiceList' + MetadataIdentifier MetadataIdentifier `json:"metadataIdentifier,omitempty"` +} + +func unmarshalBasicAlertsMetaDataProperties(body []byte) (BasicAlertsMetaDataProperties, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["metadataIdentifier"] { + case string(MetadataIdentifierMonitorServiceList): + var msl MonitorServiceList + err := json.Unmarshal(body, &msl) + return msl, err + default: + var amdp AlertsMetaDataProperties + err := json.Unmarshal(body, &amdp) + return amdp, err + } +} +func unmarshalBasicAlertsMetaDataPropertiesArray(body []byte) ([]BasicAlertsMetaDataProperties, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + amdpArray := make([]BasicAlertsMetaDataProperties, len(rawMessages)) + + for index, rawMessage := range rawMessages { + amdp, err := unmarshalBasicAlertsMetaDataProperties(*rawMessage) + if err != nil { + return nil, err + } + amdpArray[index] = amdp + } + return amdpArray, nil +} + +// MarshalJSON is the custom marshaler for AlertsMetaDataProperties. +func (amdp AlertsMetaDataProperties) MarshalJSON() ([]byte, error) { + amdp.MetadataIdentifier = MetadataIdentifierAlertsMetaDataProperties + objectMap := make(map[string]interface{}) + if amdp.MetadataIdentifier != "" { + objectMap["metadataIdentifier"] = amdp.MetadataIdentifier + } + return json.Marshal(objectMap) +} + +// AsMonitorServiceList is the BasicAlertsMetaDataProperties implementation for AlertsMetaDataProperties. +func (amdp AlertsMetaDataProperties) AsMonitorServiceList() (*MonitorServiceList, bool) { + return nil, false +} + +// AsAlertsMetaDataProperties is the BasicAlertsMetaDataProperties implementation for AlertsMetaDataProperties. +func (amdp AlertsMetaDataProperties) AsAlertsMetaDataProperties() (*AlertsMetaDataProperties, bool) { + return &amdp, true +} + +// AsBasicAlertsMetaDataProperties is the BasicAlertsMetaDataProperties implementation for AlertsMetaDataProperties. +func (amdp AlertsMetaDataProperties) AsBasicAlertsMetaDataProperties() (BasicAlertsMetaDataProperties, bool) { + return &amdp, true +} + // AlertsSummary summary of alerts based on the input filters and 'groupby' parameters. type AlertsSummary struct { autorest.Response `json:"-"` @@ -1237,6 +1355,50 @@ func (mr ManagedResource) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } +// MonitorServiceDetails details of a monitor service +type MonitorServiceDetails struct { + // Name - Monitor service name + Name *string `json:"name,omitempty"` + // DisplayName - Monitor service display name + DisplayName *string `json:"displayName,omitempty"` +} + +// MonitorServiceList monitor service details +type MonitorServiceList struct { + // Data - Array of operations + Data *[]MonitorServiceDetails `json:"data,omitempty"` + // MetadataIdentifier - Possible values include: 'MetadataIdentifierAlertsMetaDataProperties', 'MetadataIdentifierMonitorServiceList' + MetadataIdentifier MetadataIdentifier `json:"metadataIdentifier,omitempty"` +} + +// MarshalJSON is the custom marshaler for MonitorServiceList. +func (msl MonitorServiceList) MarshalJSON() ([]byte, error) { + msl.MetadataIdentifier = MetadataIdentifierMonitorServiceList + objectMap := make(map[string]interface{}) + if msl.Data != nil { + objectMap["data"] = msl.Data + } + if msl.MetadataIdentifier != "" { + objectMap["metadataIdentifier"] = msl.MetadataIdentifier + } + return json.Marshal(objectMap) +} + +// AsMonitorServiceList is the BasicAlertsMetaDataProperties implementation for MonitorServiceList. +func (msl MonitorServiceList) AsMonitorServiceList() (*MonitorServiceList, bool) { + return &msl, true +} + +// AsAlertsMetaDataProperties is the BasicAlertsMetaDataProperties implementation for MonitorServiceList. +func (msl MonitorServiceList) AsAlertsMetaDataProperties() (*AlertsMetaDataProperties, bool) { + return nil, false +} + +// AsBasicAlertsMetaDataProperties is the BasicAlertsMetaDataProperties implementation for MonitorServiceList. +func (msl MonitorServiceList) AsBasicAlertsMetaDataProperties() (BasicAlertsMetaDataProperties, bool) { + return &msl, true +} + // Operation operation provided by provider type Operation struct { // Name - Name of the operation