diff --git a/internal/services/costmanagement/anomaly_alert_resource.go b/internal/services/costmanagement/anomaly_alert_resource.go new file mode 100644 index 000000000000..0450be62a433 --- /dev/null +++ b/internal/services/costmanagement/anomaly_alert_resource.go @@ -0,0 +1,220 @@ +package costmanagement + +import ( + "context" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions" + "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/costmanagement/parse" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" + "github.com/hashicorp/terraform-provider-azurerm/utils" +) + +var _ sdk.Resource = AnomalyAlertResource{} + +type AnomalyAlertResource struct{} + +func (AnomalyAlertResource) Arguments() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + }, + + "email_subject": { + Type: pluginsdk.TypeString, + Required: true, + }, + + "email_addresses": { + Type: pluginsdk.TypeSet, + Required: true, + MinItems: 1, + Elem: &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + ValidateFunc: validation.StringIsNotEmpty, + }, + }, + + "message": { + Type: pluginsdk.TypeString, + Optional: true, + }, + } +} + +func (AnomalyAlertResource) Attributes() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{} +} + +func (AnomalyAlertResource) ModelObject() interface{} { + return nil +} + +func (AnomalyAlertResource) ResourceType() string { + return "azurerm_costmanagement_anomaly_alert" +} + +func (r AnomalyAlertResource) Create() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.CostManagement.ScheduledActionsClient + subscriptionId := metadata.Client.Account.SubscriptionId + id := scheduledactions.NewScopedScheduledActionID(fmt.Sprint("/subscriptions/", subscriptionId), "dailyanomalybyresourcegroup") + + existing, err := client.GetByScope(ctx, id) + if err != nil && !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking for presence of existing %s: %+v", id, err) + } + if !response.WasNotFound(existing.HttpResponse) { + return metadata.ResourceRequiresImport(r.ResourceType(), id) + } + + emailAddressesRaw := metadata.ResourceData.Get("email_addresses").(*pluginsdk.Set).List() + emailAddresses := utils.ExpandStringSlice(emailAddressesRaw) + viewId := parse.NewAnomalyAlertViewIdID(subscriptionId, "ms:DailyAnomalyByResourceGroup") + schedule := scheduledactions.ScheduleProperties{ + Frequency: scheduledactions.ScheduleFrequencyDaily, + HourOfDay: utils.Int64(int64(12)), + DayOfMonth: utils.Int64(int64(0)), + } + schedule.SetEndDateAsTime(time.Now().AddDate(1, 0, 0)) + schedule.SetStartDateAsTime(time.Now()) + param := scheduledactions.ScheduledAction{ + Kind: utils.ToPtr(scheduledactions.ScheduledActionKindInsightAlert), + Type: utils.String("Microsoft.CostManagement/ScheduledActions"), + Properties: &scheduledactions.ScheduledActionProperties{ + DisplayName: metadata.ResourceData.Get("name").(string), + Status: scheduledactions.ScheduledActionStatusEnabled, + ViewId: viewId.ID(), + Scope: utils.String(fmt.Sprint("/subscriptions/", subscriptionId)), + FileDestination: &scheduledactions.FileDestination{ + FileFormats: &[]scheduledactions.FileFormat{}, + }, + Notification: scheduledactions.NotificationProperties{ + Subject: metadata.ResourceData.Get("email_subject").(string), + Message: utils.String(metadata.ResourceData.Get("message").(string)), + To: *emailAddresses, + }, + Schedule: schedule, + }, + } + if _, err := client.CreateOrUpdateByScope(ctx, id, param); err != nil { + return fmt.Errorf("creating %s: %+v", id, err) + } + + metadata.SetID(id) + return nil + }, + } +} + +func (r AnomalyAlertResource) Update() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.CostManagement.ScheduledActionsClient + + id, err := scheduledactions.ParseScopedScheduledActionID(metadata.ResourceData.Get("id").(string)) + if err != nil { + return err + } + + emailAddressesRaw := metadata.ResourceData.Get("email_addresses").(*pluginsdk.Set).List() + emailAddresses := utils.ExpandStringSlice(emailAddressesRaw) + + subscriptionId := metadata.Client.Account.SubscriptionId + viewId := parse.NewAnomalyAlertViewIdID(subscriptionId, "ms:DailyAnomalyByResourceGroup") + + schedule := scheduledactions.ScheduleProperties{ + Frequency: scheduledactions.ScheduleFrequencyDaily, + HourOfDay: utils.Int64(int64(12)), + DayOfMonth: utils.Int64(int64(0)), + } + schedule.SetEndDateAsTime(time.Now().AddDate(1, 0, 0)) + schedule.SetStartDateAsTime(time.Now()) + + param := scheduledactions.ScheduledAction{ + Kind: utils.ToPtr(scheduledactions.ScheduledActionKindInsightAlert), + Properties: &scheduledactions.ScheduledActionProperties{ + DisplayName: metadata.ResourceData.Get("name").(string), + Scope: utils.String(fmt.Sprint("/subscriptions/", subscriptionId)), + Status: scheduledactions.ScheduledActionStatusEnabled, + ViewId: viewId.ID(), + Notification: scheduledactions.NotificationProperties{ + Subject: metadata.ResourceData.Get("email_subject").(string), + Message: utils.String(metadata.ResourceData.Get("message").(string)), + To: *emailAddresses, + }, + Schedule: schedule, + }, + } + if _, err := client.CreateOrUpdateByScope(ctx, *id, param); err != nil { + return fmt.Errorf("creating %s: %+v", id, err) + } + + metadata.SetID(id) + return nil + }, + } +} + +func (AnomalyAlertResource) Read() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 5 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.CostManagement.ScheduledActionsClient + + id, err := scheduledactions.ParseScopedScheduledActionID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + resp, err := client.GetByScope(ctx, *id) + if err != nil { + if response.WasNotFound(resp.HttpResponse) { + return metadata.MarkAsGone(id) + } + + return fmt.Errorf("retrieving %s: %+v", id, err) + } + + metadata.ResourceData.Set("name", resp.Model.Properties.DisplayName) + metadata.ResourceData.Set("email_subject", resp.Model.Properties.Notification.Subject) + metadata.ResourceData.Set("email_addresses", resp.Model.Properties.Notification.To) + metadata.ResourceData.Set("message", resp.Model.Properties.Notification.Message) + + return nil + }, + } +} + +func (AnomalyAlertResource) Delete() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.CostManagement.ScheduledActionsClient + + id, err := scheduledactions.ParseScopedScheduledActionID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + _, err = client.DeleteByScope(ctx, *id) + if err != nil { + return fmt.Errorf("deleting %s: %+v", *id, err) + } + + return nil + }, + } +} + +func (AnomalyAlertResource) IDValidationFunc() pluginsdk.SchemaValidateFunc { + return scheduledactions.ValidateScopedScheduledActionID +} diff --git a/internal/services/costmanagement/anomaly_alert_resource_test.go b/internal/services/costmanagement/anomaly_alert_resource_test.go new file mode 100644 index 000000000000..6b8b37993c48 --- /dev/null +++ b/internal/services/costmanagement/anomaly_alert_resource_test.go @@ -0,0 +1,55 @@ +package costmanagement_test + +import ( + "context" + "fmt" + "testing" + + "github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" + "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/utils" +) + +type AnomalyAlertResource struct{} + +func TestAccResourceAnomalyAlert_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_costmanagement_anomaly_alert", "test") + testResource := AnomalyAlertResource{} + data.ResourceTest(t, testResource, []acceptance.TestStep{ + data.ApplyStep(testResource.basicConfig, testResource), + data.ImportStep(), + }) +} + +// go install && make acctests SERVICE='costmanagement' TESTARGS='-run=TestAccResourceAnomalyAlert_basic' + +func (AnomalyAlertResource) Exists(ctx context.Context, client *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { + id, err := scheduledactions.ParseScopedScheduledActionID(state.ID) + if err != nil { + return nil, err + } + + resp, err := client.CostManagement.ScheduledActionsClient.GetByScope(ctx, *id) + if err != nil { + return nil, fmt.Errorf("retrieving %s: %+v", *id, err) + } + + return utils.Bool(resp.Model.Properties != nil), nil +} + +func (AnomalyAlertResource) basicConfig(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_costmanagement_anomaly_alert" "test" { + name = "acctestRG-%d" + email_subject = "Hi" + email_addresses = ["test@test.com", "test@hashicorp.developer"] + message = "Oops, cost anomaly" +} +`, data.RandomInteger) +} diff --git a/internal/services/costmanagement/client/client.go b/internal/services/costmanagement/client/client.go index a72e8e4735eb..fc6435895f3b 100644 --- a/internal/services/costmanagement/client/client.go +++ b/internal/services/costmanagement/client/client.go @@ -2,18 +2,24 @@ package client import ( "github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2021-10-01/exports" + "github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions" "github.com/hashicorp/terraform-provider-azurerm/internal/common" ) type Client struct { - ExportClient *exports.ExportsClient + ExportClient *exports.ExportsClient + ScheduledActionsClient *scheduledactions.ScheduledActionsClient } func NewClient(o *common.ClientOptions) *Client { ExportClient := exports.NewExportsClientWithBaseURI(o.ResourceManagerEndpoint) o.ConfigureClient(&ExportClient.Client, o.ResourceManagerAuthorizer) + ScheduledActionsClient := scheduledactions.NewScheduledActionsClientWithBaseURI(o.ResourceManagerEndpoint) + o.ConfigureClient(&ScheduledActionsClient.Client, o.ResourceManagerAuthorizer) + return &Client{ - ExportClient: &ExportClient, + ExportClient: &ExportClient, + ScheduledActionsClient: &ScheduledActionsClient, } } diff --git a/internal/services/costmanagement/parse/anomaly_alert_view_id.go b/internal/services/costmanagement/parse/anomaly_alert_view_id.go new file mode 100644 index 000000000000..074d47549768 --- /dev/null +++ b/internal/services/costmanagement/parse/anomaly_alert_view_id.go @@ -0,0 +1,61 @@ +package parse + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +type AnomalyAlertViewIdId struct { + SubscriptionId string + ViewName string +} + +func NewAnomalyAlertViewIdID(subscriptionId, viewName string) AnomalyAlertViewIdId { + return AnomalyAlertViewIdId{ + SubscriptionId: subscriptionId, + ViewName: viewName, + } +} + +func (id AnomalyAlertViewIdId) String() string { + segments := []string{ + fmt.Sprintf("View Name %q", id.ViewName), + } + segmentsStr := strings.Join(segments, " / ") + return fmt.Sprintf("%s: (%s)", "Anomaly Alert View Id", segmentsStr) +} + +func (id AnomalyAlertViewIdId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.CostManagement/views/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ViewName) +} + +// AnomalyAlertViewIdID parses a AnomalyAlertViewId ID into an AnomalyAlertViewIdId struct +func AnomalyAlertViewIdID(input string) (*AnomalyAlertViewIdId, error) { + id, err := resourceids.ParseAzureResourceID(input) + if err != nil { + return nil, err + } + + resourceId := AnomalyAlertViewIdId{ + SubscriptionId: id.SubscriptionID, + } + + if resourceId.SubscriptionId == "" { + return nil, fmt.Errorf("ID was missing the 'subscriptions' element") + } + + if resourceId.ViewName, err = id.PopSegment("views"); err != nil { + return nil, err + } + + if err := id.ValidateNoEmptySegments(input); err != nil { + return nil, err + } + + return &resourceId, nil +} diff --git a/internal/services/costmanagement/parse/anomaly_alert_view_id_test.go b/internal/services/costmanagement/parse/anomaly_alert_view_id_test.go new file mode 100644 index 000000000000..84568b6003cc --- /dev/null +++ b/internal/services/costmanagement/parse/anomaly_alert_view_id_test.go @@ -0,0 +1,96 @@ +package parse + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.Id = AnomalyAlertViewIdId{} + +func TestAnomalyAlertViewIdIDFormatter(t *testing.T) { + actual := NewAnomalyAlertViewIdID("12345678-1234-9876-4563-123456789012", "ms:DailyAnomalyByResourceGroup").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.CostManagement/views/ms:DailyAnomalyByResourceGroup" + if actual != expected { + t.Fatalf("Expected %q but got %q", expected, actual) + } +} + +func TestAnomalyAlertViewIdID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AnomalyAlertViewIdId + }{ + + { + // empty + Input: "", + Error: true, + }, + + { + // missing SubscriptionId + Input: "/", + Error: true, + }, + + { + // missing value for SubscriptionId + Input: "/subscriptions/", + Error: true, + }, + + { + // missing ViewName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.CostManagement/", + Error: true, + }, + + { + // missing value for ViewName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.CostManagement/views/", + Error: true, + }, + + { + // valid + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.CostManagement/views/ms:DailyAnomalyByResourceGroup", + Expected: &AnomalyAlertViewIdId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ViewName: "ms:DailyAnomalyByResourceGroup", + }, + }, + + { + // upper-cased + Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/PROVIDERS/MICROSOFT.COSTMANAGEMENT/VIEWS/MS:DAILYANOMALYBYRESOURCEGROUP", + Error: true, + }, + } + + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := AnomalyAlertViewIdID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %s", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + if actual.ViewName != v.Expected.ViewName { + t.Fatalf("Expected %q but got %q for ViewName", v.Expected.ViewName, actual.ViewName) + } + } +} diff --git a/internal/services/costmanagement/registration.go b/internal/services/costmanagement/registration.go index 58423f9cdae8..47f3043afe3e 100644 --- a/internal/services/costmanagement/registration.go +++ b/internal/services/costmanagement/registration.go @@ -21,6 +21,7 @@ func (r Registration) Resources() []sdk.Resource { BillingAccountCostManagementExportResource{}, ResourceGroupCostManagementExportResource{}, SubscriptionCostManagementExportResource{}, + AnomalyAlertResource{}, } } diff --git a/internal/services/costmanagement/resourceids.go b/internal/services/costmanagement/resourceids.go index 1a28582a1045..b01c83e67572 100644 --- a/internal/services/costmanagement/resourceids.go +++ b/internal/services/costmanagement/resourceids.go @@ -2,3 +2,4 @@ package costmanagement //go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=SubscriptionCostManagementExport -id=/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.CostManagement/exports/export1 //go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=ResourceGroupCostManagementExport -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.CostManagement/exports/export1 +//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=AnomalyAlertViewId -id=/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.CostManagement/views/ms:DailyAnomalyByResourceGroup diff --git a/internal/services/costmanagement/validate/anomaly_alert_view_id_id.go b/internal/services/costmanagement/validate/anomaly_alert_view_id_id.go new file mode 100644 index 000000000000..b9ab02890e99 --- /dev/null +++ b/internal/services/costmanagement/validate/anomaly_alert_view_id_id.go @@ -0,0 +1,23 @@ +package validate + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import ( + "fmt" + + "github.com/hashicorp/terraform-provider-azurerm/internal/services/costmanagement/parse" +) + +func AnomalyAlertViewIdID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := parse.AnomalyAlertViewIdID(v); err != nil { + errors = append(errors, err) + } + + return +} diff --git a/internal/services/costmanagement/validate/anomaly_alert_view_id_id_test.go b/internal/services/costmanagement/validate/anomaly_alert_view_id_id_test.go new file mode 100644 index 000000000000..a0df4732ddac --- /dev/null +++ b/internal/services/costmanagement/validate/anomaly_alert_view_id_id_test.go @@ -0,0 +1,64 @@ +package validate + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import "testing" + +func TestAnomalyAlertViewIdID(t *testing.T) { + cases := []struct { + Input string + Valid bool + }{ + + { + // empty + Input: "", + Valid: false, + }, + + { + // missing SubscriptionId + Input: "/", + Valid: false, + }, + + { + // missing value for SubscriptionId + Input: "/subscriptions/", + Valid: false, + }, + + { + // missing ViewName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.CostManagement/", + Valid: false, + }, + + { + // missing value for ViewName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.CostManagement/views/", + Valid: false, + }, + + { + // valid + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.CostManagement/views/ms:DailyAnomalyByResourceGroup", + Valid: true, + }, + + { + // upper-cased + Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/PROVIDERS/MICROSOFT.COSTMANAGEMENT/VIEWS/MS:DAILYANOMALYBYRESOURCEGROUP", + Valid: false, + }, + } + for _, tc := range cases { + t.Logf("[DEBUG] Testing Value %s", tc.Input) + _, errors := AnomalyAlertViewIdID(tc.Input, "test") + valid := len(errors) == 0 + + if tc.Valid != valid { + t.Fatalf("Expected %t but got %t", tc.Valid, valid) + } + } +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/README.md new file mode 100644 index 000000000000..2c7b89ea05e1 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/README.md @@ -0,0 +1,233 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions` Documentation + +The `scheduledactions` SDK allows for interaction with the Azure Resource Manager Service `costmanagement` (API Version `2022-06-01-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions" +``` + + +### Client Initialization + +```go +client := scheduledactions.NewScheduledActionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ScheduledActionsClient.CheckNameAvailability` + +```go +ctx := context.TODO() + +payload := scheduledactions.CheckNameAvailabilityRequest{ + // ... +} + + +read, err := client.CheckNameAvailability(ctx, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ScheduledActionsClient.CheckNameAvailabilityByScope` + +```go +ctx := context.TODO() +id := scheduledactions.NewScopeID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group") + +payload := scheduledactions.CheckNameAvailabilityRequest{ + // ... +} + + +read, err := client.CheckNameAvailabilityByScope(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ScheduledActionsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := scheduledactions.NewScheduledActionID("nameValue") + +payload := scheduledactions.ScheduledAction{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ScheduledActionsClient.CreateOrUpdateByScope` + +```go +ctx := context.TODO() +id := scheduledactions.NewScopedScheduledActionID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", "nameValue") + +payload := scheduledactions.ScheduledAction{ + // ... +} + + +read, err := client.CreateOrUpdateByScope(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ScheduledActionsClient.Delete` + +```go +ctx := context.TODO() +id := scheduledactions.NewScheduledActionID("nameValue") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ScheduledActionsClient.DeleteByScope` + +```go +ctx := context.TODO() +id := scheduledactions.NewScopedScheduledActionID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", "nameValue") + +read, err := client.DeleteByScope(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ScheduledActionsClient.Execute` + +```go +ctx := context.TODO() +id := scheduledactions.NewScheduledActionID("nameValue") + +read, err := client.Execute(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ScheduledActionsClient.ExecuteByScope` + +```go +ctx := context.TODO() +id := scheduledactions.NewScopedScheduledActionID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", "nameValue") + +read, err := client.ExecuteByScope(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ScheduledActionsClient.Get` + +```go +ctx := context.TODO() +id := scheduledactions.NewScheduledActionID("nameValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ScheduledActionsClient.GetByScope` + +```go +ctx := context.TODO() +id := scheduledactions.NewScopedScheduledActionID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", "nameValue") + +read, err := client.GetByScope(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ScheduledActionsClient.List` + +```go +ctx := context.TODO() + + +// alternatively `client.List(ctx, scheduledactions.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, scheduledactions.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ScheduledActionsClient.ListByScope` + +```go +ctx := context.TODO() +id := scheduledactions.NewScopeID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group") + +// alternatively `client.ListByScope(ctx, id, scheduledactions.DefaultListByScopeOperationOptions())` can be used to do batched pagination +items, err := client.ListByScopeComplete(ctx, id, scheduledactions.DefaultListByScopeOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/client.go new file mode 100644 index 000000000000..da8bf8d2cd52 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/client.go @@ -0,0 +1,18 @@ +package scheduledactions + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScheduledActionsClient struct { + Client autorest.Client + baseUri string +} + +func NewScheduledActionsClientWithBaseURI(endpoint string) ScheduledActionsClient { + return ScheduledActionsClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/constants.go new file mode 100644 index 000000000000..7baaacd762c5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/constants.go @@ -0,0 +1,226 @@ +package scheduledactions + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityReason string + +const ( + CheckNameAvailabilityReasonAlreadyExists CheckNameAvailabilityReason = "AlreadyExists" + CheckNameAvailabilityReasonInvalid CheckNameAvailabilityReason = "Invalid" +) + +func PossibleValuesForCheckNameAvailabilityReason() []string { + return []string{ + string(CheckNameAvailabilityReasonAlreadyExists), + string(CheckNameAvailabilityReasonInvalid), + } +} + +func parseCheckNameAvailabilityReason(input string) (*CheckNameAvailabilityReason, error) { + vals := map[string]CheckNameAvailabilityReason{ + "alreadyexists": CheckNameAvailabilityReasonAlreadyExists, + "invalid": CheckNameAvailabilityReasonInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CheckNameAvailabilityReason(input) + return &out, nil +} + +type DaysOfWeek string + +const ( + DaysOfWeekFriday DaysOfWeek = "Friday" + DaysOfWeekMonday DaysOfWeek = "Monday" + DaysOfWeekSaturday DaysOfWeek = "Saturday" + DaysOfWeekSunday DaysOfWeek = "Sunday" + DaysOfWeekThursday DaysOfWeek = "Thursday" + DaysOfWeekTuesday DaysOfWeek = "Tuesday" + DaysOfWeekWednesday DaysOfWeek = "Wednesday" +) + +func PossibleValuesForDaysOfWeek() []string { + return []string{ + string(DaysOfWeekFriday), + string(DaysOfWeekMonday), + string(DaysOfWeekSaturday), + string(DaysOfWeekSunday), + string(DaysOfWeekThursday), + string(DaysOfWeekTuesday), + string(DaysOfWeekWednesday), + } +} + +func parseDaysOfWeek(input string) (*DaysOfWeek, error) { + vals := map[string]DaysOfWeek{ + "friday": DaysOfWeekFriday, + "monday": DaysOfWeekMonday, + "saturday": DaysOfWeekSaturday, + "sunday": DaysOfWeekSunday, + "thursday": DaysOfWeekThursday, + "tuesday": DaysOfWeekTuesday, + "wednesday": DaysOfWeekWednesday, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DaysOfWeek(input) + return &out, nil +} + +type FileFormat string + +const ( + FileFormatCsv FileFormat = "Csv" +) + +func PossibleValuesForFileFormat() []string { + return []string{ + string(FileFormatCsv), + } +} + +func parseFileFormat(input string) (*FileFormat, error) { + vals := map[string]FileFormat{ + "csv": FileFormatCsv, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FileFormat(input) + return &out, nil +} + +type ScheduleFrequency string + +const ( + ScheduleFrequencyDaily ScheduleFrequency = "Daily" + ScheduleFrequencyMonthly ScheduleFrequency = "Monthly" + ScheduleFrequencyWeekly ScheduleFrequency = "Weekly" +) + +func PossibleValuesForScheduleFrequency() []string { + return []string{ + string(ScheduleFrequencyDaily), + string(ScheduleFrequencyMonthly), + string(ScheduleFrequencyWeekly), + } +} + +func parseScheduleFrequency(input string) (*ScheduleFrequency, error) { + vals := map[string]ScheduleFrequency{ + "daily": ScheduleFrequencyDaily, + "monthly": ScheduleFrequencyMonthly, + "weekly": ScheduleFrequencyWeekly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScheduleFrequency(input) + return &out, nil +} + +type ScheduledActionKind string + +const ( + ScheduledActionKindEmail ScheduledActionKind = "Email" + ScheduledActionKindInsightAlert ScheduledActionKind = "InsightAlert" +) + +func PossibleValuesForScheduledActionKind() []string { + return []string{ + string(ScheduledActionKindEmail), + string(ScheduledActionKindInsightAlert), + } +} + +func parseScheduledActionKind(input string) (*ScheduledActionKind, error) { + vals := map[string]ScheduledActionKind{ + "email": ScheduledActionKindEmail, + "insightalert": ScheduledActionKindInsightAlert, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScheduledActionKind(input) + return &out, nil +} + +type ScheduledActionStatus string + +const ( + ScheduledActionStatusDisabled ScheduledActionStatus = "Disabled" + ScheduledActionStatusEnabled ScheduledActionStatus = "Enabled" +) + +func PossibleValuesForScheduledActionStatus() []string { + return []string{ + string(ScheduledActionStatusDisabled), + string(ScheduledActionStatusEnabled), + } +} + +func parseScheduledActionStatus(input string) (*ScheduledActionStatus, error) { + vals := map[string]ScheduledActionStatus{ + "disabled": ScheduledActionStatusDisabled, + "enabled": ScheduledActionStatusEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScheduledActionStatus(input) + return &out, nil +} + +type WeeksOfMonth string + +const ( + WeeksOfMonthFirst WeeksOfMonth = "First" + WeeksOfMonthFourth WeeksOfMonth = "Fourth" + WeeksOfMonthLast WeeksOfMonth = "Last" + WeeksOfMonthSecond WeeksOfMonth = "Second" + WeeksOfMonthThird WeeksOfMonth = "Third" +) + +func PossibleValuesForWeeksOfMonth() []string { + return []string{ + string(WeeksOfMonthFirst), + string(WeeksOfMonthFourth), + string(WeeksOfMonthLast), + string(WeeksOfMonthSecond), + string(WeeksOfMonthThird), + } +} + +func parseWeeksOfMonth(input string) (*WeeksOfMonth, error) { + vals := map[string]WeeksOfMonth{ + "first": WeeksOfMonthFirst, + "fourth": WeeksOfMonthFourth, + "last": WeeksOfMonthLast, + "second": WeeksOfMonthSecond, + "third": WeeksOfMonthThird, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WeeksOfMonth(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/id_scheduledaction.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/id_scheduledaction.go new file mode 100644 index 000000000000..6de26f4a59d8 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/id_scheduledaction.go @@ -0,0 +1,98 @@ +package scheduledactions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = ScheduledActionId{} + +// ScheduledActionId is a struct representing the Resource ID for a Scheduled Action +type ScheduledActionId struct { + Name string +} + +// NewScheduledActionID returns a new ScheduledActionId struct +func NewScheduledActionID(name string) ScheduledActionId { + return ScheduledActionId{ + Name: name, + } +} + +// ParseScheduledActionID parses 'input' into a ScheduledActionId +func ParseScheduledActionID(input string) (*ScheduledActionId, error) { + parser := resourceids.NewParserFromResourceIdType(ScheduledActionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := ScheduledActionId{} + + if id.Name, ok = parsed.Parsed["name"]; !ok { + return nil, fmt.Errorf("the segment 'name' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseScheduledActionIDInsensitively parses 'input' case-insensitively into a ScheduledActionId +// note: this method should only be used for API response data and not user input +func ParseScheduledActionIDInsensitively(input string) (*ScheduledActionId, error) { + parser := resourceids.NewParserFromResourceIdType(ScheduledActionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := ScheduledActionId{} + + if id.Name, ok = parsed.Parsed["name"]; !ok { + return nil, fmt.Errorf("the segment 'name' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateScheduledActionID checks that 'input' can be parsed as a Scheduled Action ID +func ValidateScheduledActionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseScheduledActionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Scheduled Action ID +func (id ScheduledActionId) ID() string { + fmtString := "/providers/Microsoft.CostManagement/scheduledActions/%s" + return fmt.Sprintf(fmtString, id.Name) +} + +// Segments returns a slice of Resource ID Segments which comprise this Scheduled Action ID +func (id ScheduledActionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftCostManagement", "Microsoft.CostManagement", "Microsoft.CostManagement"), + resourceids.StaticSegment("staticScheduledActions", "scheduledActions", "scheduledActions"), + resourceids.UserSpecifiedSegment("name", "nameValue"), + } +} + +// String returns a human-readable description of this Scheduled Action ID +func (id ScheduledActionId) String() string { + components := []string{ + fmt.Sprintf("Name: %q", id.Name), + } + return fmt.Sprintf("Scheduled Action (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/id_scopedscheduledaction.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/id_scopedscheduledaction.go new file mode 100644 index 000000000000..a95745e6cc76 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/id_scopedscheduledaction.go @@ -0,0 +1,110 @@ +package scheduledactions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = ScopedScheduledActionId{} + +// ScopedScheduledActionId is a struct representing the Resource ID for a Scoped Scheduled Action +type ScopedScheduledActionId struct { + Scope string + Name string +} + +// NewScopedScheduledActionID returns a new ScopedScheduledActionId struct +func NewScopedScheduledActionID(scope string, name string) ScopedScheduledActionId { + return ScopedScheduledActionId{ + Scope: scope, + Name: name, + } +} + +// ParseScopedScheduledActionID parses 'input' into a ScopedScheduledActionId +func ParseScopedScheduledActionID(input string) (*ScopedScheduledActionId, error) { + parser := resourceids.NewParserFromResourceIdType(ScopedScheduledActionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := ScopedScheduledActionId{} + + if id.Scope, ok = parsed.Parsed["scope"]; !ok { + return nil, fmt.Errorf("the segment 'scope' was not found in the resource id %q", input) + } + + if id.Name, ok = parsed.Parsed["name"]; !ok { + return nil, fmt.Errorf("the segment 'name' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseScopedScheduledActionIDInsensitively parses 'input' case-insensitively into a ScopedScheduledActionId +// note: this method should only be used for API response data and not user input +func ParseScopedScheduledActionIDInsensitively(input string) (*ScopedScheduledActionId, error) { + parser := resourceids.NewParserFromResourceIdType(ScopedScheduledActionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := ScopedScheduledActionId{} + + if id.Scope, ok = parsed.Parsed["scope"]; !ok { + return nil, fmt.Errorf("the segment 'scope' was not found in the resource id %q", input) + } + + if id.Name, ok = parsed.Parsed["name"]; !ok { + return nil, fmt.Errorf("the segment 'name' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateScopedScheduledActionID checks that 'input' can be parsed as a Scoped Scheduled Action ID +func ValidateScopedScheduledActionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseScopedScheduledActionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Scoped Scheduled Action ID +func (id ScopedScheduledActionId) ID() string { + fmtString := "/%s/providers/Microsoft.CostManagement/scheduledActions/%s" + return fmt.Sprintf(fmtString, strings.TrimPrefix(id.Scope, "/"), id.Name) +} + +// Segments returns a slice of Resource ID Segments which comprise this Scoped Scheduled Action ID +func (id ScopedScheduledActionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.ScopeSegment("scope", "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftCostManagement", "Microsoft.CostManagement", "Microsoft.CostManagement"), + resourceids.StaticSegment("staticScheduledActions", "scheduledActions", "scheduledActions"), + resourceids.UserSpecifiedSegment("name", "nameValue"), + } +} + +// String returns a human-readable description of this Scoped Scheduled Action ID +func (id ScopedScheduledActionId) String() string { + components := []string{ + fmt.Sprintf("Scope: %q", id.Scope), + fmt.Sprintf("Name: %q", id.Name), + } + return fmt.Sprintf("Scoped Scheduled Action (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/method_checknameavailability_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/method_checknameavailability_autorest.go new file mode 100644 index 000000000000..78fadd2e60f9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/method_checknameavailability_autorest.go @@ -0,0 +1,69 @@ +package scheduledactions + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + Model *CheckNameAvailabilityResponse +} + +// CheckNameAvailability ... +func (c ScheduledActionsClient) CheckNameAvailability(ctx context.Context, input CheckNameAvailabilityRequest) (result CheckNameAvailabilityOperationResponse, err error) { + req, err := c.preparerForCheckNameAvailability(ctx, input) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduledactions.ScheduledActionsClient", "CheckNameAvailability", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduledactions.ScheduledActionsClient", "CheckNameAvailability", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForCheckNameAvailability(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduledactions.ScheduledActionsClient", "CheckNameAvailability", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForCheckNameAvailability prepares the CheckNameAvailability request. +func (c ScheduledActionsClient) preparerForCheckNameAvailability(ctx context.Context, input CheckNameAvailabilityRequest) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath("/providers/Microsoft.CostManagement/checkNameAvailability"), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForCheckNameAvailability handles the response to the CheckNameAvailability request. The method always +// closes the http.Response Body. +func (c ScheduledActionsClient) responderForCheckNameAvailability(resp *http.Response) (result CheckNameAvailabilityOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/method_checknameavailabilitybyscope_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/method_checknameavailabilitybyscope_autorest.go new file mode 100644 index 000000000000..7af7b5b0d0af --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/method_checknameavailabilitybyscope_autorest.go @@ -0,0 +1,71 @@ +package scheduledactions + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityByScopeOperationResponse struct { + HttpResponse *http.Response + Model *CheckNameAvailabilityResponse +} + +// CheckNameAvailabilityByScope ... +func (c ScheduledActionsClient) CheckNameAvailabilityByScope(ctx context.Context, id commonids.ScopeId, input CheckNameAvailabilityRequest) (result CheckNameAvailabilityByScopeOperationResponse, err error) { + req, err := c.preparerForCheckNameAvailabilityByScope(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduledactions.ScheduledActionsClient", "CheckNameAvailabilityByScope", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduledactions.ScheduledActionsClient", "CheckNameAvailabilityByScope", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForCheckNameAvailabilityByScope(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduledactions.ScheduledActionsClient", "CheckNameAvailabilityByScope", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForCheckNameAvailabilityByScope prepares the CheckNameAvailabilityByScope request. +func (c ScheduledActionsClient) preparerForCheckNameAvailabilityByScope(ctx context.Context, id commonids.ScopeId, input CheckNameAvailabilityRequest) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.CostManagement/checkNameAvailability", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForCheckNameAvailabilityByScope handles the response to the CheckNameAvailabilityByScope request. The method always +// closes the http.Response Body. +func (c ScheduledActionsClient) responderForCheckNameAvailabilityByScope(resp *http.Response) (result CheckNameAvailabilityByScopeOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/method_createorupdate_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/method_createorupdate_autorest.go new file mode 100644 index 000000000000..cedfaf5d41a2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/method_createorupdate_autorest.go @@ -0,0 +1,69 @@ +package scheduledactions + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + Model *ScheduledAction +} + +// CreateOrUpdate ... +func (c ScheduledActionsClient) CreateOrUpdate(ctx context.Context, id ScheduledActionId, input ScheduledAction) (result CreateOrUpdateOperationResponse, err error) { + req, err := c.preparerForCreateOrUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduledactions.ScheduledActionsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduledactions.ScheduledActionsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForCreateOrUpdate(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduledactions.ScheduledActionsClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForCreateOrUpdate prepares the CreateOrUpdate request. +func (c ScheduledActionsClient) preparerForCreateOrUpdate(ctx context.Context, id ScheduledActionId, input ScheduledAction) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForCreateOrUpdate handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (c ScheduledActionsClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/method_createorupdatebyscope_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/method_createorupdatebyscope_autorest.go new file mode 100644 index 000000000000..41b6ef378162 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/method_createorupdatebyscope_autorest.go @@ -0,0 +1,69 @@ +package scheduledactions + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateByScopeOperationResponse struct { + HttpResponse *http.Response + Model *ScheduledAction +} + +// CreateOrUpdateByScope ... +func (c ScheduledActionsClient) CreateOrUpdateByScope(ctx context.Context, id ScopedScheduledActionId, input ScheduledAction) (result CreateOrUpdateByScopeOperationResponse, err error) { + req, err := c.preparerForCreateOrUpdateByScope(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduledactions.ScheduledActionsClient", "CreateOrUpdateByScope", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduledactions.ScheduledActionsClient", "CreateOrUpdateByScope", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForCreateOrUpdateByScope(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduledactions.ScheduledActionsClient", "CreateOrUpdateByScope", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForCreateOrUpdateByScope prepares the CreateOrUpdateByScope request. +func (c ScheduledActionsClient) preparerForCreateOrUpdateByScope(ctx context.Context, id ScopedScheduledActionId, input ScheduledAction) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForCreateOrUpdateByScope handles the response to the CreateOrUpdateByScope request. The method always +// closes the http.Response Body. +func (c ScheduledActionsClient) responderForCreateOrUpdateByScope(resp *http.Response) (result CreateOrUpdateByScopeOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/method_delete_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/method_delete_autorest.go new file mode 100644 index 000000000000..8eac54a64c88 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/method_delete_autorest.go @@ -0,0 +1,66 @@ +package scheduledactions + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response +} + +// Delete ... +func (c ScheduledActionsClient) Delete(ctx context.Context, id ScheduledActionId) (result DeleteOperationResponse, err error) { + req, err := c.preparerForDelete(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduledactions.ScheduledActionsClient", "Delete", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduledactions.ScheduledActionsClient", "Delete", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForDelete(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduledactions.ScheduledActionsClient", "Delete", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForDelete prepares the Delete request. +func (c ScheduledActionsClient) preparerForDelete(ctx context.Context, id ScheduledActionId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsDelete(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForDelete handles the response to the Delete request. The method always +// closes the http.Response Body. +func (c ScheduledActionsClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/method_deletebyscope_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/method_deletebyscope_autorest.go new file mode 100644 index 000000000000..90cfdea3ab85 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/method_deletebyscope_autorest.go @@ -0,0 +1,66 @@ +package scheduledactions + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteByScopeOperationResponse struct { + HttpResponse *http.Response +} + +// DeleteByScope ... +func (c ScheduledActionsClient) DeleteByScope(ctx context.Context, id ScopedScheduledActionId) (result DeleteByScopeOperationResponse, err error) { + req, err := c.preparerForDeleteByScope(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduledactions.ScheduledActionsClient", "DeleteByScope", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduledactions.ScheduledActionsClient", "DeleteByScope", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForDeleteByScope(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduledactions.ScheduledActionsClient", "DeleteByScope", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForDeleteByScope prepares the DeleteByScope request. +func (c ScheduledActionsClient) preparerForDeleteByScope(ctx context.Context, id ScopedScheduledActionId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsDelete(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForDeleteByScope handles the response to the DeleteByScope request. The method always +// closes the http.Response Body. +func (c ScheduledActionsClient) responderForDeleteByScope(resp *http.Response) (result DeleteByScopeOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/method_execute_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/method_execute_autorest.go new file mode 100644 index 000000000000..9454940b58ac --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/method_execute_autorest.go @@ -0,0 +1,67 @@ +package scheduledactions + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExecuteOperationResponse struct { + HttpResponse *http.Response +} + +// Execute ... +func (c ScheduledActionsClient) Execute(ctx context.Context, id ScheduledActionId) (result ExecuteOperationResponse, err error) { + req, err := c.preparerForExecute(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduledactions.ScheduledActionsClient", "Execute", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduledactions.ScheduledActionsClient", "Execute", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForExecute(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduledactions.ScheduledActionsClient", "Execute", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForExecute prepares the Execute request. +func (c ScheduledActionsClient) preparerForExecute(ctx context.Context, id ScheduledActionId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/execute", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForExecute handles the response to the Execute request. The method always +// closes the http.Response Body. +func (c ScheduledActionsClient) responderForExecute(resp *http.Response) (result ExecuteOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/method_executebyscope_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/method_executebyscope_autorest.go new file mode 100644 index 000000000000..8307bab29fd7 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/method_executebyscope_autorest.go @@ -0,0 +1,67 @@ +package scheduledactions + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExecuteByScopeOperationResponse struct { + HttpResponse *http.Response +} + +// ExecuteByScope ... +func (c ScheduledActionsClient) ExecuteByScope(ctx context.Context, id ScopedScheduledActionId) (result ExecuteByScopeOperationResponse, err error) { + req, err := c.preparerForExecuteByScope(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduledactions.ScheduledActionsClient", "ExecuteByScope", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduledactions.ScheduledActionsClient", "ExecuteByScope", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForExecuteByScope(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduledactions.ScheduledActionsClient", "ExecuteByScope", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForExecuteByScope prepares the ExecuteByScope request. +func (c ScheduledActionsClient) preparerForExecuteByScope(ctx context.Context, id ScopedScheduledActionId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/execute", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForExecuteByScope handles the response to the ExecuteByScope request. The method always +// closes the http.Response Body. +func (c ScheduledActionsClient) responderForExecuteByScope(resp *http.Response) (result ExecuteByScopeOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/method_get_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/method_get_autorest.go new file mode 100644 index 000000000000..5825ccc136a8 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/method_get_autorest.go @@ -0,0 +1,68 @@ +package scheduledactions + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + Model *ScheduledAction +} + +// Get ... +func (c ScheduledActionsClient) Get(ctx context.Context, id ScheduledActionId) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduledactions.ScheduledActionsClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduledactions.ScheduledActionsClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduledactions.ScheduledActionsClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c ScheduledActionsClient) preparerForGet(ctx context.Context, id ScheduledActionId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGet handles the response to the Get request. The method always +// closes the http.Response Body. +func (c ScheduledActionsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/method_getbyscope_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/method_getbyscope_autorest.go new file mode 100644 index 000000000000..9af56b66c285 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/method_getbyscope_autorest.go @@ -0,0 +1,68 @@ +package scheduledactions + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetByScopeOperationResponse struct { + HttpResponse *http.Response + Model *ScheduledAction +} + +// GetByScope ... +func (c ScheduledActionsClient) GetByScope(ctx context.Context, id ScopedScheduledActionId) (result GetByScopeOperationResponse, err error) { + req, err := c.preparerForGetByScope(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduledactions.ScheduledActionsClient", "GetByScope", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduledactions.ScheduledActionsClient", "GetByScope", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGetByScope(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduledactions.ScheduledActionsClient", "GetByScope", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGetByScope prepares the GetByScope request. +func (c ScheduledActionsClient) preparerForGetByScope(ctx context.Context, id ScopedScheduledActionId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGetByScope handles the response to the GetByScope request. The method always +// closes the http.Response Body. +func (c ScheduledActionsClient) responderForGetByScope(resp *http.Response) (result GetByScopeOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/method_list_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/method_list_autorest.go new file mode 100644 index 000000000000..5bb04d1e0801 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/method_list_autorest.go @@ -0,0 +1,215 @@ +package scheduledactions + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + Model *[]ScheduledAction + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) +} + +type ListCompleteResult struct { + Items []ScheduledAction +} + +func (r ListOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +type ListOperationOptions struct { + Filter *string +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o ListOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Filter != nil { + out["$filter"] = *o.Filter + } + + return out +} + +// List ... +func (c ScheduledActionsClient) List(ctx context.Context, options ListOperationOptions) (resp ListOperationResponse, err error) { + req, err := c.preparerForList(ctx, options) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduledactions.ScheduledActionsClient", "List", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduledactions.ScheduledActionsClient", "List", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForList(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduledactions.ScheduledActionsClient", "List", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForList prepares the List request. +func (c ScheduledActionsClient) preparerForList(ctx context.Context, options ListOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath("/providers/Microsoft.CostManagement/scheduledActions"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListWithNextLink prepares the List request with the given nextLink token. +func (c ScheduledActionsClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForList handles the response to the List request. The method always +// closes the http.Response Body. +func (c ScheduledActionsClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { + type page struct { + Values []ScheduledAction `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { + req, err := c.preparerForListWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduledactions.ScheduledActionsClient", "List", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduledactions.ScheduledActionsClient", "List", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForList(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduledactions.ScheduledActionsClient", "List", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// ListComplete retrieves all of the results into a single object +func (c ScheduledActionsClient) ListComplete(ctx context.Context, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, options, ScheduledActionOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c ScheduledActionsClient) ListCompleteMatchingPredicate(ctx context.Context, options ListOperationOptions, predicate ScheduledActionOperationPredicate) (resp ListCompleteResult, err error) { + items := make([]ScheduledAction, 0) + + page, err := c.List(ctx, options) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListCompleteResult{ + Items: items, + } + return out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/method_listbyscope_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/method_listbyscope_autorest.go new file mode 100644 index 000000000000..bc250993be68 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/method_listbyscope_autorest.go @@ -0,0 +1,216 @@ +package scheduledactions + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByScopeOperationResponse struct { + HttpResponse *http.Response + Model *[]ScheduledAction + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListByScopeOperationResponse, error) +} + +type ListByScopeCompleteResult struct { + Items []ScheduledAction +} + +func (r ListByScopeOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListByScopeOperationResponse) LoadMore(ctx context.Context) (resp ListByScopeOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +type ListByScopeOperationOptions struct { + Filter *string +} + +func DefaultListByScopeOperationOptions() ListByScopeOperationOptions { + return ListByScopeOperationOptions{} +} + +func (o ListByScopeOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o ListByScopeOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Filter != nil { + out["$filter"] = *o.Filter + } + + return out +} + +// ListByScope ... +func (c ScheduledActionsClient) ListByScope(ctx context.Context, id commonids.ScopeId, options ListByScopeOperationOptions) (resp ListByScopeOperationResponse, err error) { + req, err := c.preparerForListByScope(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduledactions.ScheduledActionsClient", "ListByScope", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduledactions.ScheduledActionsClient", "ListByScope", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForListByScope(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduledactions.ScheduledActionsClient", "ListByScope", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForListByScope prepares the ListByScope request. +func (c ScheduledActionsClient) preparerForListByScope(ctx context.Context, id commonids.ScopeId, options ListByScopeOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.CostManagement/scheduledActions", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListByScopeWithNextLink prepares the ListByScope request with the given nextLink token. +func (c ScheduledActionsClient) preparerForListByScopeWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForListByScope handles the response to the ListByScope request. The method always +// closes the http.Response Body. +func (c ScheduledActionsClient) responderForListByScope(resp *http.Response) (result ListByScopeOperationResponse, err error) { + type page struct { + Values []ScheduledAction `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByScopeOperationResponse, err error) { + req, err := c.preparerForListByScopeWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduledactions.ScheduledActionsClient", "ListByScope", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduledactions.ScheduledActionsClient", "ListByScope", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForListByScope(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "scheduledactions.ScheduledActionsClient", "ListByScope", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// ListByScopeComplete retrieves all of the results into a single object +func (c ScheduledActionsClient) ListByScopeComplete(ctx context.Context, id commonids.ScopeId, options ListByScopeOperationOptions) (ListByScopeCompleteResult, error) { + return c.ListByScopeCompleteMatchingPredicate(ctx, id, options, ScheduledActionOperationPredicate{}) +} + +// ListByScopeCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c ScheduledActionsClient) ListByScopeCompleteMatchingPredicate(ctx context.Context, id commonids.ScopeId, options ListByScopeOperationOptions, predicate ScheduledActionOperationPredicate) (resp ListByScopeCompleteResult, err error) { + items := make([]ScheduledAction, 0) + + page, err := c.ListByScope(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListByScopeCompleteResult{ + Items: items, + } + return out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/model_checknameavailabilityrequest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/model_checknameavailabilityrequest.go new file mode 100644 index 000000000000..2c2eeed8fb06 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/model_checknameavailabilityrequest.go @@ -0,0 +1,9 @@ +package scheduledactions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityRequest struct { + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/model_checknameavailabilityresponse.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/model_checknameavailabilityresponse.go new file mode 100644 index 000000000000..9cf3c0cf44af --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/model_checknameavailabilityresponse.go @@ -0,0 +1,10 @@ +package scheduledactions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityResponse struct { + Message *string `json:"message,omitempty"` + NameAvailable *bool `json:"nameAvailable,omitempty"` + Reason *CheckNameAvailabilityReason `json:"reason,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/model_filedestination.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/model_filedestination.go new file mode 100644 index 000000000000..8691cf8ce3e9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/model_filedestination.go @@ -0,0 +1,8 @@ +package scheduledactions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FileDestination struct { + FileFormats *[]FileFormat `json:"fileFormats,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/model_notificationproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/model_notificationproperties.go new file mode 100644 index 000000000000..a579ae878522 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/model_notificationproperties.go @@ -0,0 +1,10 @@ +package scheduledactions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NotificationProperties struct { + Message *string `json:"message,omitempty"` + Subject string `json:"subject"` + To []string `json:"to"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/model_scheduledaction.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/model_scheduledaction.go new file mode 100644 index 000000000000..ecb01cdf187f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/model_scheduledaction.go @@ -0,0 +1,18 @@ +package scheduledactions + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScheduledAction struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Kind *ScheduledActionKind `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ScheduledActionProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/model_scheduledactionproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/model_scheduledactionproperties.go new file mode 100644 index 000000000000..2610efa9651f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/model_scheduledactionproperties.go @@ -0,0 +1,14 @@ +package scheduledactions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScheduledActionProperties struct { + DisplayName string `json:"displayName"` + FileDestination *FileDestination `json:"fileDestination,omitempty"` + Notification NotificationProperties `json:"notification"` + Schedule ScheduleProperties `json:"schedule"` + Scope *string `json:"scope,omitempty"` + Status ScheduledActionStatus `json:"status"` + ViewId string `json:"viewId"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/model_scheduleproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/model_scheduleproperties.go new file mode 100644 index 000000000000..081153c4cede --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/model_scheduleproperties.go @@ -0,0 +1,38 @@ +package scheduledactions + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScheduleProperties struct { + DayOfMonth *int64 `json:"dayOfMonth,omitempty"` + DaysOfWeek *[]DaysOfWeek `json:"daysOfWeek,omitempty"` + EndDate string `json:"endDate"` + Frequency ScheduleFrequency `json:"frequency"` + HourOfDay *int64 `json:"hourOfDay,omitempty"` + StartDate string `json:"startDate"` + WeeksOfMonth *[]WeeksOfMonth `json:"weeksOfMonth,omitempty"` +} + +func (o *ScheduleProperties) GetEndDateAsTime() (*time.Time, error) { + return dates.ParseAsFormat(&o.EndDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *ScheduleProperties) SetEndDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndDate = formatted +} + +func (o *ScheduleProperties) GetStartDateAsTime() (*time.Time, error) { + return dates.ParseAsFormat(&o.StartDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *ScheduleProperties) SetStartDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartDate = formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/predicates.go new file mode 100644 index 000000000000..5905d9d85c8e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/predicates.go @@ -0,0 +1,29 @@ +package scheduledactions + +type ScheduledActionOperationPredicate struct { + ETag *string + Id *string + Name *string + Type *string +} + +func (p ScheduledActionOperationPredicate) Matches(input ScheduledAction) bool { + + if p.ETag != nil && (input.ETag == nil && *p.ETag != *input.ETag) { + return false + } + + if p.Id != nil && (input.Id == nil && *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil && *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil && *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/version.go new file mode 100644 index 000000000000..a8a14260e27a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions/version.go @@ -0,0 +1,12 @@ +package scheduledactions + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2022-06-01-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/scheduledactions/%s", defaultApiVersion) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 75bb8d9d41f3..2476f99d59ed 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -229,6 +229,7 @@ github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2022-05-15/cosmosdb github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2022-05-15/managedcassandras github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2022-05-15/sqldedicatedgateway github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2021-10-01/exports +github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2022-06-01-preview/scheduledactions github.com/hashicorp/go-azure-sdk/resource-manager/customproviders/2018-09-01-preview/customresourceprovider github.com/hashicorp/go-azure-sdk/resource-manager/dashboard/2022-08-01/grafanaresource github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector