From bfdc81b3250453fe3ace7f6d87ec57c6fe8c5db0 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Fri, 11 Dec 2020 10:39:45 +0000 Subject: [PATCH] CodeGen from PR 11901 in Azure/azure-rest-api-specs Update swagger with new properties (#11901) --- .../2019-03-01/alertsmanagement/CHANGELOG.md | 54 +++ .../2019-03-01/alertsmanagement/alerts.go | 74 ++++ .../alertsmanagementapi/interfaces.go | 11 +- .../mgmt/2019-03-01/alertsmanagement/enums.go | 15 + .../2019-03-01/alertsmanagement/models.go | 176 +++++++- .../2019-03-01/alertsmanagement/operations.go | 2 + .../smartdetectoralertrules.go | 7 + .../alertsmanagement/smartgroups.go | 381 ------------------ 8 files changed, 318 insertions(+), 402 deletions(-) create mode 100644 services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/CHANGELOG.md delete mode 100644 services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/smartgroups.go diff --git a/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/CHANGELOG.md b/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/CHANGELOG.md new file mode 100644 index 000000000000..6b81076b8471 --- /dev/null +++ b/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/CHANGELOG.md @@ -0,0 +1,54 @@ +Generated from https://github.com/Azure/azure-rest-api-specs/tree/3c764635e7d442b3e74caf593029fcd440b3ef82 + +Code generator @microsoft.azure/autorest.go@~2.1.161 + +## Breaking Changes + +- Function `NewAlertsListPage` parameter(s) have been changed from `(func(context.Context, AlertsList) (AlertsList, error))` to `(AlertsList, func(context.Context, AlertsList) (AlertsList, error))` +- Function `NewAlertRulesListPage` parameter(s) have been changed from `(func(context.Context, AlertRulesList) (AlertRulesList, error))` to `(AlertRulesList, func(context.Context, AlertRulesList) (AlertRulesList, error))` +- Function `NewOperationsListPage` parameter(s) have been changed from `(func(context.Context, OperationsList) (OperationsList, error))` to `(OperationsList, func(context.Context, OperationsList) (OperationsList, error))` +- Function `SmartGroupsClient.ChangeState` has been removed +- Function `SmartGroupsClient.GetByIDResponder` has been removed +- Function `SmartGroupsClient.GetHistoryPreparer` has been removed +- Function `SmartGroupsClient.GetAllSender` has been removed +- Function `SmartGroupsClient.ChangeStateSender` has been removed +- Function `SmartGroupsClient.GetAll` has been removed +- Function `SmartGroupsClient.GetHistorySender` has been removed +- Function `SmartGroupsClient.GetHistory` has been removed +- Function `SmartGroupsClient.ChangeStateResponder` has been removed +- Function `SmartGroupsClient.GetByIDSender` has been removed +- Function `SmartGroupsClient.GetHistoryResponder` has been removed +- Function `SmartGroupsClient.GetByID` has been removed +- Function `NewSmartGroupsClientWithBaseURI` has been removed +- Function `SmartGroupsClient.GetAllResponder` has been removed +- Function `SmartGroupsClient.ChangeStatePreparer` has been removed +- Function `SmartGroupsClient.GetAllPreparer` has been removed +- Function `SmartGroupsClient.GetByIDPreparer` has been removed +- Function `NewSmartGroupsClient` has been removed +- Struct `SmartGroupsClient` has been removed +- Field `autorest.Response` of struct `SmartGroupsList` has been removed +- Field `autorest.Response` of struct `SmartGroup` has been removed +- Field `autorest.Response` of struct `SmartGroupModification` has been removed + +## New Content + +- New const `MetadataIdentifierMonitorServiceList` +- New const `MetadataIdentifierAlertsMetaDataProperties` +- New function `AlertsMetaDataProperties.MarshalJSON() ([]byte, error)` +- New function `AlertsClient.MetaDataResponder(*http.Response) (AlertsMetaData, error)` +- New function `*AlertsMetaData.UnmarshalJSON([]byte) error` +- New function `MonitorServiceList.AsMonitorServiceList() (*MonitorServiceList, bool)` +- New function `AlertsMetaDataProperties.AsMonitorServiceList() (*MonitorServiceList, bool)` +- New function `MonitorServiceList.MarshalJSON() ([]byte, error)` +- New function `AlertsClient.MetaDataPreparer(context.Context) (*http.Request, error)` +- New function `AlertsMetaDataProperties.AsAlertsMetaDataProperties() (*AlertsMetaDataProperties, bool)` +- New function `AlertsClient.MetaData(context.Context) (AlertsMetaData, error)` +- New function `PossibleMetadataIdentifierValues() []MetadataIdentifier` +- New function `MonitorServiceList.AsBasicAlertsMetaDataProperties() (BasicAlertsMetaDataProperties, bool)` +- New function `AlertsClient.MetaDataSender(*http.Request) (*http.Response, error)` +- New function `MonitorServiceList.AsAlertsMetaDataProperties() (*AlertsMetaDataProperties, bool)` +- New function `AlertsMetaDataProperties.AsBasicAlertsMetaDataProperties() (BasicAlertsMetaDataProperties, bool)` +- New struct `AlertsMetaData` +- New struct `AlertsMetaDataProperties` +- New struct `MonitorServiceDetails` +- New struct `MonitorServiceList` diff --git a/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/alerts.go b/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/alerts.go index 2fb3ff945b64..04252f8342c7 100644 --- a/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/alerts.go +++ b/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/alerts.go @@ -77,6 +77,7 @@ func (client AlertsClient) ChangeState(ctx context.Context, alertID string, newS result, err = client.ChangeStateResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "alertsmanagement.AlertsClient", "ChangeState", resp, "Failure responding to request") + return } return @@ -178,9 +179,11 @@ func (client AlertsClient) GetAll(ctx context.Context, targetResource string, ta result.al, err = client.GetAllResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "alertsmanagement.AlertsClient", "GetAll", resp, "Failure responding to request") + return } if result.al.hasNextLink() && result.al.IsEmpty() { err = result.NextWithContext(ctx) + return } return @@ -346,6 +349,7 @@ func (client AlertsClient) GetByID(ctx context.Context, alertID string) (result result, err = client.GetByIDResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "alertsmanagement.AlertsClient", "GetByID", resp, "Failure responding to request") + return } return @@ -425,6 +429,7 @@ func (client AlertsClient) GetHistory(ctx context.Context, alertID string) (resu result, err = client.GetHistoryResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "alertsmanagement.AlertsClient", "GetHistory", resp, "Failure responding to request") + return } return @@ -514,6 +519,7 @@ func (client AlertsClient) GetSummary(ctx context.Context, groupby AlertsSummary result, err = client.GetSummaryResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "alertsmanagement.AlertsClient", "GetSummary", resp, "Failure responding to request") + return } return @@ -589,3 +595,71 @@ 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 + } + + return +} + +// MetaDataPreparer prepares the MetaData request. +func (client AlertsClient) MetaDataPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2018-05-05" + 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 client.Send(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, + 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 index 3ad0485eac3c..8d9874c29a78 100644 --- a/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/alertsmanagementapi/interfaces.go +++ b/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/alertsmanagementapi/interfaces.go @@ -39,20 +39,11 @@ 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) -// 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) diff --git a/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/enums.go b/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/enums.go index 934bf3ad9180..8ea02ff63335 100644 --- a/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/enums.go +++ b/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/enums.go @@ -120,6 +120,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 diff --git a/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/models.go b/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/models.go index 5de81aaeff0e..57221f315173 100644 --- a/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/models.go +++ b/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/models.go @@ -369,8 +369,11 @@ func (page AlertRulesListPage) Values() []AlertRule { } // Creates a new instance of the AlertRulesListPage type. -func NewAlertRulesListPage(getNextPage func(context.Context, AlertRulesList) (AlertRulesList, error)) AlertRulesListPage { - return AlertRulesListPage{fn: getNextPage} +func NewAlertRulesListPage(cur AlertRulesList, getNextPage func(context.Context, AlertRulesList) (AlertRulesList, error)) AlertRulesListPage { + return AlertRulesListPage{ + fn: getNextPage, + arl: cur, + } } // AlertsList list the alerts. @@ -525,8 +528,114 @@ func (page AlertsListPage) Values() []Alert { } // Creates a new instance of the AlertsListPage type. -func NewAlertsListPage(getNextPage func(context.Context, AlertsList) (AlertsList, error)) AlertsListPage { - return AlertsListPage{fn: getNextPage} +func NewAlertsListPage(cur AlertsList, getNextPage func(context.Context, AlertsList) (AlertsList, error)) AlertsListPage { + return AlertsListPage{ + fn: getNextPage, + al: cur, + } +} + +// 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. @@ -584,7 +693,8 @@ type AzureResource struct { Name *string `json:"name,omitempty"` } -// Detector the detector information. By default this is not populated, unless it's specified in expandDetector +// 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"` @@ -697,6 +807,50 @@ func (e Essentials) 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 @@ -869,8 +1023,11 @@ func (page OperationsListPage) Values() []Operation { } // Creates a new instance of the OperationsListPage type. -func NewOperationsListPage(getNextPage func(context.Context, OperationsList) (OperationsList, error)) OperationsListPage { - return OperationsListPage{fn: getNextPage} +func NewOperationsListPage(cur OperationsList, getNextPage func(context.Context, OperationsList) (OperationsList, error)) OperationsListPage { + return OperationsListPage{ + fn: getNextPage, + ol: cur, + } } // ProxyResource an azure resource object @@ -893,7 +1050,6 @@ type SmartDetectorErrorResponse struct { // 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"` @@ -973,8 +1129,7 @@ type SmartGroupAggregatedProperty struct { // SmartGroupModification alert Modification details type SmartGroupModification struct { - autorest.Response `json:"-"` - Properties *SmartGroupModificationProperties `json:"properties,omitempty"` + Properties *SmartGroupModificationProperties `json:"properties,omitempty"` // ID - READ-ONLY; Azure resource Id ID *string `json:"id,omitempty"` // Type - READ-ONLY; Azure resource type @@ -1099,7 +1254,6 @@ func (sgp SmartGroupProperties) MarshalJSON() ([]byte, error) { // 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 diff --git a/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/operations.go b/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/operations.go index 3f9689cefcf5..a8b8739a4567 100644 --- a/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/operations.go +++ b/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/operations.go @@ -70,9 +70,11 @@ func (client OperationsClient) List(ctx context.Context) (result OperationsListP result.ol, err = client.ListResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "alertsmanagement.OperationsClient", "List", resp, "Failure responding to request") + return } if result.ol.hasNextLink() && result.ol.IsEmpty() { err = result.NextWithContext(ctx) + return } return diff --git a/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/smartdetectoralertrules.go b/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/smartdetectoralertrules.go index bfcaf4c41b4e..5ac710ee55f9 100644 --- a/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/smartdetectoralertrules.go +++ b/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/smartdetectoralertrules.go @@ -88,6 +88,7 @@ func (client SmartDetectorAlertRulesClient) CreateOrUpdate(ctx context.Context, result, err = client.CreateOrUpdateResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "alertsmanagement.SmartDetectorAlertRulesClient", "CreateOrUpdate", resp, "Failure responding to request") + return } return @@ -165,6 +166,7 @@ func (client SmartDetectorAlertRulesClient) Delete(ctx context.Context, resource result, err = client.DeleteResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "alertsmanagement.SmartDetectorAlertRulesClient", "Delete", resp, "Failure responding to request") + return } return @@ -240,6 +242,7 @@ func (client SmartDetectorAlertRulesClient) Get(ctx context.Context, resourceGro result, err = client.GetResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "alertsmanagement.SmartDetectorAlertRulesClient", "Get", resp, "Failure responding to request") + return } return @@ -316,9 +319,11 @@ func (client SmartDetectorAlertRulesClient) List(ctx context.Context) (result Al result.arl, err = client.ListResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "alertsmanagement.SmartDetectorAlertRulesClient", "List", resp, "Failure responding to request") + return } if result.arl.hasNextLink() && result.arl.IsEmpty() { err = result.NextWithContext(ctx) + return } return @@ -429,9 +434,11 @@ func (client SmartDetectorAlertRulesClient) ListByResourceGroup(ctx context.Cont result.arl, err = client.ListByResourceGroupResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "alertsmanagement.SmartDetectorAlertRulesClient", "ListByResourceGroup", resp, "Failure responding to request") + return } if result.arl.hasNextLink() && result.arl.IsEmpty() { err = result.NextWithContext(ctx) + return } return diff --git a/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/smartgroups.go b/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/smartgroups.go deleted file mode 100644 index 6a805edf9e59..000000000000 --- a/services/alertsmanagement/mgmt/2019-03-01/alertsmanagement/smartgroups.go +++ /dev/null @@ -1,381 +0,0 @@ -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 using a custom endpoint. Use -// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). -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 client.Send(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, - 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 client.Send(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, - 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 client.Send(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, - 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 client.Send(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, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -}