diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alertsmanagement_live_test.go b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alertsmanagement_live_test.go new file mode 100644 index 000000000000..07fed5c8bfdc --- /dev/null +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/alertsmanagement_live_test.go @@ -0,0 +1,227 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package armalertsmanagement_test + +import ( + "context" + "fmt" + "testing" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/alertsmanagement/armalertsmanagement" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/testutil" + "github.com/stretchr/testify/suite" +) + +type AlertsManagementTestSuite struct { + suite.Suite + + ctx context.Context + cred azcore.TokenCredential + options *arm.ClientOptions + alertProcessingRuleName string + location string + resourceGroupName string + subscriptionId string +} + +func (testsuite *AlertsManagementTestSuite) SetupSuite() { + testutil.StartRecording(testsuite.T(), "sdk/resourcemanager/alertsmanagement/armalertsmanagement/testdata") + + testsuite.ctx = context.Background() + testsuite.cred, testsuite.options = testutil.GetCredAndClientOptions(testsuite.T()) + testsuite.alertProcessingRuleName, _ = recording.GenerateAlphaNumericID(testsuite.T(), "alertpro", 14, false) + testsuite.location = testutil.GetEnv("LOCATION", "westus") + testsuite.resourceGroupName = testutil.GetEnv("RESOURCE_GROUP_NAME", "scenarioTestTempGroup") + testsuite.subscriptionId = testutil.GetEnv("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + resourceGroup, _, err := testutil.CreateResourceGroup(testsuite.ctx, testsuite.subscriptionId, testsuite.cred, testsuite.options, testsuite.location) + testsuite.Require().NoError(err) + testsuite.resourceGroupName = *resourceGroup.Name +} + +func (testsuite *AlertsManagementTestSuite) TearDownSuite() { + _, err := testutil.DeleteResourceGroup(testsuite.ctx, testsuite.subscriptionId, testsuite.cred, testsuite.options, testsuite.resourceGroupName) + testsuite.Require().NoError(err) + testutil.StopRecording(testsuite.T()) +} + +func TestAlertsManagementTestSuite(t *testing.T) { + suite.Run(t, new(AlertsManagementTestSuite)) +} + +// Microsoft.AlertsManagement/operations +func (testsuite *AlertsManagementTestSuite) TestOperations() { + var err error + // From step Operations_List + fmt.Println("Call operation: Operations_List") + operationsClient, err := armalertsmanagement.NewOperationsClient(testsuite.cred, testsuite.options) + testsuite.Require().NoError(err) + operationsClientNewListPager := operationsClient.NewListPager(nil) + for operationsClientNewListPager.More() { + _, err := operationsClientNewListPager.NextPage(testsuite.ctx) + testsuite.Require().NoError(err) + break + } +} + +// Microsoft.AlertsManagement/alerts/{alertId} +func (testsuite *AlertsManagementTestSuite) TestAlerts() { + var err error + // From step Alerts_GetAll + fmt.Println("Call operation: Alerts_GetAll") + alertsClient, err := armalertsmanagement.NewAlertsClient(testsuite.subscriptionId, testsuite.cred, testsuite.options) + testsuite.Require().NoError(err) + alertsClientNewGetAllPager := alertsClient.NewGetAllPager(&armalertsmanagement.AlertsClientGetAllOptions{TargetResource: nil, + TargetResourceType: nil, + TargetResourceGroup: nil, + MonitorService: nil, + MonitorCondition: nil, + Severity: nil, + AlertState: nil, + AlertRule: nil, + SmartGroupID: nil, + IncludeContext: nil, + IncludeEgressConfig: nil, + PageCount: nil, + SortBy: nil, + SortOrder: nil, + Select: nil, + TimeRange: nil, + CustomTimeRange: nil, + }) + for alertsClientNewGetAllPager.More() { + _, err := alertsClientNewGetAllPager.NextPage(testsuite.ctx) + testsuite.Require().NoError(err) + break + } + + // From step Alerts_GetSummary + fmt.Println("Call operation: Alerts_GetSummary") + _, err = alertsClient.GetSummary(testsuite.ctx, armalertsmanagement.AlertsSummaryGroupByFields("severity,alertState"), &armalertsmanagement.AlertsClientGetSummaryOptions{IncludeSmartGroupsCount: nil, + TargetResource: nil, + TargetResourceType: nil, + TargetResourceGroup: nil, + MonitorService: nil, + MonitorCondition: nil, + Severity: nil, + AlertState: nil, + AlertRule: nil, + TimeRange: nil, + CustomTimeRange: nil, + }) + testsuite.Require().NoError(err) +} + +// Microsoft.AlertsManagement/actionRules/{alertProcessingRuleName} +func (testsuite *AlertsManagementTestSuite) TestAlertProcessingRules() { + globalLocation := "Global" + var err error + // From step AlertProcessingRules_CreateOrUpdate + fmt.Println("Call operation: AlertProcessingRules_CreateOrUpdate") + alertProcessingRulesClient, err := armalertsmanagement.NewAlertProcessingRulesClient(testsuite.subscriptionId, testsuite.cred, testsuite.options) + testsuite.Require().NoError(err) + _, err = alertProcessingRulesClient.CreateOrUpdate(testsuite.ctx, testsuite.resourceGroupName, testsuite.alertProcessingRuleName, armalertsmanagement.AlertProcessingRule{ + Location: to.Ptr(globalLocation), + Tags: map[string]*string{}, + Properties: &armalertsmanagement.AlertProcessingRuleProperties{ + Description: to.Ptr("Remove all ActionGroups outside business hours"), + Actions: []armalertsmanagement.ActionClassification{ + &armalertsmanagement.RemoveAllActionGroups{ + ActionType: to.Ptr(armalertsmanagement.ActionTypeRemoveAllActionGroups), + }}, + Enabled: to.Ptr(true), + Schedule: &armalertsmanagement.Schedule{ + Recurrences: []armalertsmanagement.RecurrenceClassification{ + &armalertsmanagement.DailyRecurrence{ + EndTime: to.Ptr("09:00:00"), + RecurrenceType: to.Ptr(armalertsmanagement.RecurrenceTypeDaily), + StartTime: to.Ptr("17:00:00"), + }, + &armalertsmanagement.WeeklyRecurrence{ + RecurrenceType: to.Ptr(armalertsmanagement.RecurrenceTypeWeekly), + DaysOfWeek: []*armalertsmanagement.DaysOfWeek{ + to.Ptr(armalertsmanagement.DaysOfWeekSaturday), + to.Ptr(armalertsmanagement.DaysOfWeekSunday)}, + }}, + TimeZone: to.Ptr("Eastern Standard Time"), + }, + Scopes: []*string{ + to.Ptr("/subscriptions/" + testsuite.subscriptionId + "/resourceGroups/" + testsuite.resourceGroupName)}, + }, + }, nil) + testsuite.Require().NoError(err) + + // From step AlertProcessingRules_ListBySubscription + fmt.Println("Call operation: AlertProcessingRules_ListBySubscription") + alertProcessingRulesClientNewListBySubscriptionPager := alertProcessingRulesClient.NewListBySubscriptionPager(nil) + for alertProcessingRulesClientNewListBySubscriptionPager.More() { + _, err := alertProcessingRulesClientNewListBySubscriptionPager.NextPage(testsuite.ctx) + testsuite.Require().NoError(err) + break + } + + // From step AlertProcessingRules_GetByName + fmt.Println("Call operation: AlertProcessingRules_GetByName") + _, err = alertProcessingRulesClient.GetByName(testsuite.ctx, testsuite.resourceGroupName, testsuite.alertProcessingRuleName, nil) + testsuite.Require().NoError(err) + + // From step AlertProcessingRules_ListByResourceGroup + fmt.Println("Call operation: AlertProcessingRules_ListByResourceGroup") + alertProcessingRulesClientNewListByResourceGroupPager := alertProcessingRulesClient.NewListByResourceGroupPager(testsuite.resourceGroupName, nil) + for alertProcessingRulesClientNewListByResourceGroupPager.More() { + _, err := alertProcessingRulesClientNewListByResourceGroupPager.NextPage(testsuite.ctx) + testsuite.Require().NoError(err) + break + } + + // From step AlertProcessingRules_Update + fmt.Println("Call operation: AlertProcessingRules_Update") + _, err = alertProcessingRulesClient.Update(testsuite.ctx, testsuite.resourceGroupName, testsuite.alertProcessingRuleName, armalertsmanagement.PatchObject{ + Properties: &armalertsmanagement.PatchProperties{ + Enabled: to.Ptr(false), + }, + Tags: map[string]*string{ + "key1": to.Ptr("value1"), + "key2": to.Ptr("value2"), + }, + }, nil) + testsuite.Require().NoError(err) + + // From step AlertProcessingRules_Delete + fmt.Println("Call operation: AlertProcessingRules_Delete") + _, err = alertProcessingRulesClient.Delete(testsuite.ctx, testsuite.resourceGroupName, testsuite.alertProcessingRuleName, nil) + testsuite.Require().NoError(err) +} + +// Microsoft.AlertsManagement/smartGroups/{smartGroupId} +func (testsuite *AlertsManagementTestSuite) TestSmartGroups() { + var err error + // From step SmartGroups_GetAll + fmt.Println("Call operation: SmartGroups_GetAll") + smartGroupsClient, err := armalertsmanagement.NewSmartGroupsClient(testsuite.subscriptionId, testsuite.cred, testsuite.options) + testsuite.Require().NoError(err) + smartGroupsClientNewGetAllPager := smartGroupsClient.NewGetAllPager(&armalertsmanagement.SmartGroupsClientGetAllOptions{TargetResource: nil, + TargetResourceGroup: nil, + TargetResourceType: nil, + MonitorService: nil, + MonitorCondition: nil, + Severity: nil, + SmartGroupState: nil, + TimeRange: nil, + PageCount: nil, + SortBy: nil, + SortOrder: nil, + }) + for smartGroupsClientNewGetAllPager.More() { + _, err := smartGroupsClientNewGetAllPager.NextPage(testsuite.ctx) + testsuite.Require().NoError(err) + break + } +} diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/assets.json b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/assets.json new file mode 100644 index 000000000000..549e6517fb1f --- /dev/null +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/assets.json @@ -0,0 +1,6 @@ +{ + "AssetsRepo": "Azure/azure-sdk-assets", + "AssetsRepoPrefixPath": "go", + "TagPrefix": "go/resourcemanager/alertsmanagement/armalertsmanagement", + "Tag": "go/resourcemanager/alertsmanagement/armalertsmanagement_aa22f99525" +} diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/go.mod b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/go.mod index a3fb08a259f8..f465602f461e 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/go.mod +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/go.mod @@ -5,17 +5,25 @@ go 1.18 require ( github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 + github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 + github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v1.1.2 + github.com/stretchr/testify v1.7.0 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect + github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.0.0 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/dnaeon/go-vcr v1.1.0 // indirect github.com/golang-jwt/jwt/v4 v4.5.0 // indirect github.com/google/uuid v1.3.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect golang.org/x/crypto v0.6.0 // indirect golang.org/x/net v0.7.0 // indirect golang.org/x/sys v0.5.0 // indirect golang.org/x/text v0.7.0 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect ) diff --git a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/go.sum b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/go.sum index 8ba445a8c4da..6e2c77825a2c 100644 --- a/sdk/resourcemanager/alertsmanagement/armalertsmanagement/go.sum +++ b/sdk/resourcemanager/alertsmanagement/armalertsmanagement/go.sum @@ -4,20 +4,31 @@ github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v1.1.2 h1:mLY+pNLjCUeKhgnAJWAKhEUQM+RJQo2H1fuGSw1Ky1E= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v1.1.2/go.mod h1:FbdwsQ2EzwvXxOPcMFYO8ogEc9uMMIj3YkmCdXdAFmk= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.0.0 h1:ECsQtyERDVz3NP3kvDOTLvbQhqWp/x9EsGKtb4ogUr8= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.0.0/go.mod h1:s1tW/At+xHqjNFvWU4G0c0Qv33KOhvbGNj0RCTQDV8s= github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= +github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= @@ -27,5 +38,11 @@ golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=