diff --git a/resource-manager/redis/2023-08-01/redis/model_rediscommonpropertiesredisconfiguration.go b/resource-manager/redis/2023-08-01/redis/model_rediscommonpropertiesredisconfiguration.go index 9d4127353a9..738fc5dd4a7 100644 --- a/resource-manager/redis/2023-08-01/redis/model_rediscommonpropertiesredisconfiguration.go +++ b/resource-manager/redis/2023-08-01/redis/model_rediscommonpropertiesredisconfiguration.go @@ -14,7 +14,7 @@ type RedisCommonPropertiesRedisConfiguration struct { MaxmemoryDelta *string `json:"maxmemory-delta,omitempty"` MaxmemoryPolicy *string `json:"maxmemory-policy,omitempty"` MaxmemoryReserved *string `json:"maxmemory-reserved,omitempty"` - NotifyKeyspaceEvents string `json:"notify-keyspace-events"` + NotifyKeyspaceEvents *string `json:"notify-keyspace-events,omitempty"` PreferredDataArchiveAuthMethod *string `json:"preferred-data-archive-auth-method,omitempty"` PreferredDataPersistenceAuthMethod *string `json:"preferred-data-persistence-auth-method,omitempty"` RdbBackupEnabled *string `json:"rdb-backup-enabled,omitempty"` diff --git a/resource-manager/resources/2024-04-01/policyassignments/constants.go b/resource-manager/resources/2024-04-01/policyassignments/constants.go index 15d2935dcd7..7718c01b89b 100644 --- a/resource-manager/resources/2024-04-01/policyassignments/constants.go +++ b/resource-manager/resources/2024-04-01/policyassignments/constants.go @@ -9,6 +9,53 @@ import ( // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. +type AssignmentType string + +const ( + AssignmentTypeCustom AssignmentType = "Custom" + AssignmentTypeNotSpecified AssignmentType = "NotSpecified" + AssignmentTypeSystem AssignmentType = "System" + AssignmentTypeSystemHidden AssignmentType = "SystemHidden" +) + +func PossibleValuesForAssignmentType() []string { + return []string{ + string(AssignmentTypeCustom), + string(AssignmentTypeNotSpecified), + string(AssignmentTypeSystem), + string(AssignmentTypeSystemHidden), + } +} + +func (s *AssignmentType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAssignmentType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAssignmentType(input string) (*AssignmentType, error) { + vals := map[string]AssignmentType{ + "custom": AssignmentTypeCustom, + "notspecified": AssignmentTypeNotSpecified, + "system": AssignmentTypeSystem, + "systemhidden": AssignmentTypeSystemHidden, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AssignmentType(input) + return &out, nil +} + type EnforcementMode string const ( diff --git a/resource-manager/resources/2024-04-01/policyassignments/model_policyassignmentproperties.go b/resource-manager/resources/2024-04-01/policyassignments/model_policyassignmentproperties.go index 1495651d2da..9688849071f 100644 --- a/resource-manager/resources/2024-04-01/policyassignments/model_policyassignmentproperties.go +++ b/resource-manager/resources/2024-04-01/policyassignments/model_policyassignmentproperties.go @@ -4,10 +4,10 @@ package policyassignments // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type PolicyAssignmentProperties struct { + AssignmentType *AssignmentType `json:"assignmentType,omitempty"` Description *string `json:"description,omitempty"` DisplayName *string `json:"displayName,omitempty"` EnforcementMode *EnforcementMode `json:"enforcementMode,omitempty"` - IsSystemPolicy *bool `json:"isSystemPolicy,omitempty"` Metadata *interface{} `json:"metadata,omitempty"` NonComplianceMessages *[]NonComplianceMessage `json:"nonComplianceMessages,omitempty"` NotScopes *[]string `json:"notScopes,omitempty"` diff --git a/resource-manager/storagecache/2024-03-01/amlfilesystems/README.md b/resource-manager/storagecache/2024-03-01/amlfilesystems/README.md new file mode 100644 index 00000000000..ed8c16446be --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/amlfilesystems/README.md @@ -0,0 +1,196 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/storagecache/2024-03-01/amlfilesystems` Documentation + +The `amlfilesystems` SDK allows for interaction with the Azure Resource Manager Service `storagecache` (API Version `2024-03-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/storagecache/2024-03-01/amlfilesystems" +``` + + +### Client Initialization + +```go +client := amlfilesystems.NewAmlFilesystemsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AmlFilesystemsClient.Archive` + +```go +ctx := context.TODO() +id := amlfilesystems.NewAmlFilesystemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "amlFilesystemValue") + +payload := amlfilesystems.AmlFilesystemArchiveInfo{ + // ... +} + + +read, err := client.Archive(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AmlFilesystemsClient.CancelArchive` + +```go +ctx := context.TODO() +id := amlfilesystems.NewAmlFilesystemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "amlFilesystemValue") + +read, err := client.CancelArchive(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AmlFilesystemsClient.CheckAmlFSSubnets` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +payload := amlfilesystems.AmlFilesystemSubnetInfo{ + // ... +} + + +read, err := client.CheckAmlFSSubnets(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AmlFilesystemsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := amlfilesystems.NewAmlFilesystemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "amlFilesystemValue") + +payload := amlfilesystems.AmlFilesystem{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AmlFilesystemsClient.Delete` + +```go +ctx := context.TODO() +id := amlfilesystems.NewAmlFilesystemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "amlFilesystemValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `AmlFilesystemsClient.Get` + +```go +ctx := context.TODO() +id := amlfilesystems.NewAmlFilesystemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "amlFilesystemValue") + +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: `AmlFilesystemsClient.GetRequiredAmlFSSubnetsSize` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +payload := amlfilesystems.RequiredAmlFilesystemSubnetsSizeInfo{ + // ... +} + + +read, err := client.GetRequiredAmlFSSubnetsSize(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AmlFilesystemsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AmlFilesystemsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AmlFilesystemsClient.Update` + +```go +ctx := context.TODO() +id := amlfilesystems.NewAmlFilesystemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "amlFilesystemValue") + +payload := amlfilesystems.AmlFilesystemUpdate{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/storagecache/2024-03-01/amlfilesystems/client.go b/resource-manager/storagecache/2024-03-01/amlfilesystems/client.go new file mode 100644 index 00000000000..a9967587cb4 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/amlfilesystems/client.go @@ -0,0 +1,26 @@ +package amlfilesystems + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AmlFilesystemsClient struct { + Client *resourcemanager.Client +} + +func NewAmlFilesystemsClientWithBaseURI(sdkApi sdkEnv.Api) (*AmlFilesystemsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "amlfilesystems", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AmlFilesystemsClient: %+v", err) + } + + return &AmlFilesystemsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/storagecache/2024-03-01/amlfilesystems/constants.go b/resource-manager/storagecache/2024-03-01/amlfilesystems/constants.go new file mode 100644 index 00000000000..09f1ee9e31d --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/amlfilesystems/constants.go @@ -0,0 +1,272 @@ +package amlfilesystems + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AmlFilesystemHealthStateType string + +const ( + AmlFilesystemHealthStateTypeAvailable AmlFilesystemHealthStateType = "Available" + AmlFilesystemHealthStateTypeDegraded AmlFilesystemHealthStateType = "Degraded" + AmlFilesystemHealthStateTypeMaintenance AmlFilesystemHealthStateType = "Maintenance" + AmlFilesystemHealthStateTypeTransitioning AmlFilesystemHealthStateType = "Transitioning" + AmlFilesystemHealthStateTypeUnavailable AmlFilesystemHealthStateType = "Unavailable" +) + +func PossibleValuesForAmlFilesystemHealthStateType() []string { + return []string{ + string(AmlFilesystemHealthStateTypeAvailable), + string(AmlFilesystemHealthStateTypeDegraded), + string(AmlFilesystemHealthStateTypeMaintenance), + string(AmlFilesystemHealthStateTypeTransitioning), + string(AmlFilesystemHealthStateTypeUnavailable), + } +} + +func (s *AmlFilesystemHealthStateType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAmlFilesystemHealthStateType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAmlFilesystemHealthStateType(input string) (*AmlFilesystemHealthStateType, error) { + vals := map[string]AmlFilesystemHealthStateType{ + "available": AmlFilesystemHealthStateTypeAvailable, + "degraded": AmlFilesystemHealthStateTypeDegraded, + "maintenance": AmlFilesystemHealthStateTypeMaintenance, + "transitioning": AmlFilesystemHealthStateTypeTransitioning, + "unavailable": AmlFilesystemHealthStateTypeUnavailable, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AmlFilesystemHealthStateType(input) + return &out, nil +} + +type AmlFilesystemProvisioningStateType string + +const ( + AmlFilesystemProvisioningStateTypeCanceled AmlFilesystemProvisioningStateType = "Canceled" + AmlFilesystemProvisioningStateTypeCreating AmlFilesystemProvisioningStateType = "Creating" + AmlFilesystemProvisioningStateTypeDeleting AmlFilesystemProvisioningStateType = "Deleting" + AmlFilesystemProvisioningStateTypeFailed AmlFilesystemProvisioningStateType = "Failed" + AmlFilesystemProvisioningStateTypeSucceeded AmlFilesystemProvisioningStateType = "Succeeded" + AmlFilesystemProvisioningStateTypeUpdating AmlFilesystemProvisioningStateType = "Updating" +) + +func PossibleValuesForAmlFilesystemProvisioningStateType() []string { + return []string{ + string(AmlFilesystemProvisioningStateTypeCanceled), + string(AmlFilesystemProvisioningStateTypeCreating), + string(AmlFilesystemProvisioningStateTypeDeleting), + string(AmlFilesystemProvisioningStateTypeFailed), + string(AmlFilesystemProvisioningStateTypeSucceeded), + string(AmlFilesystemProvisioningStateTypeUpdating), + } +} + +func (s *AmlFilesystemProvisioningStateType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAmlFilesystemProvisioningStateType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAmlFilesystemProvisioningStateType(input string) (*AmlFilesystemProvisioningStateType, error) { + vals := map[string]AmlFilesystemProvisioningStateType{ + "canceled": AmlFilesystemProvisioningStateTypeCanceled, + "creating": AmlFilesystemProvisioningStateTypeCreating, + "deleting": AmlFilesystemProvisioningStateTypeDeleting, + "failed": AmlFilesystemProvisioningStateTypeFailed, + "succeeded": AmlFilesystemProvisioningStateTypeSucceeded, + "updating": AmlFilesystemProvisioningStateTypeUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AmlFilesystemProvisioningStateType(input) + return &out, nil +} + +type AmlFilesystemSquashMode string + +const ( + AmlFilesystemSquashModeAll AmlFilesystemSquashMode = "All" + AmlFilesystemSquashModeNone AmlFilesystemSquashMode = "None" + AmlFilesystemSquashModeRootOnly AmlFilesystemSquashMode = "RootOnly" +) + +func PossibleValuesForAmlFilesystemSquashMode() []string { + return []string{ + string(AmlFilesystemSquashModeAll), + string(AmlFilesystemSquashModeNone), + string(AmlFilesystemSquashModeRootOnly), + } +} + +func (s *AmlFilesystemSquashMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAmlFilesystemSquashMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAmlFilesystemSquashMode(input string) (*AmlFilesystemSquashMode, error) { + vals := map[string]AmlFilesystemSquashMode{ + "all": AmlFilesystemSquashModeAll, + "none": AmlFilesystemSquashModeNone, + "rootonly": AmlFilesystemSquashModeRootOnly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AmlFilesystemSquashMode(input) + return &out, nil +} + +type ArchiveStatusType string + +const ( + ArchiveStatusTypeCanceled ArchiveStatusType = "Canceled" + ArchiveStatusTypeCancelling ArchiveStatusType = "Cancelling" + ArchiveStatusTypeCompleted ArchiveStatusType = "Completed" + ArchiveStatusTypeFSScanInProgress ArchiveStatusType = "FSScanInProgress" + ArchiveStatusTypeFailed ArchiveStatusType = "Failed" + ArchiveStatusTypeIdle ArchiveStatusType = "Idle" + ArchiveStatusTypeInProgress ArchiveStatusType = "InProgress" + ArchiveStatusTypeNotConfigured ArchiveStatusType = "NotConfigured" +) + +func PossibleValuesForArchiveStatusType() []string { + return []string{ + string(ArchiveStatusTypeCanceled), + string(ArchiveStatusTypeCancelling), + string(ArchiveStatusTypeCompleted), + string(ArchiveStatusTypeFSScanInProgress), + string(ArchiveStatusTypeFailed), + string(ArchiveStatusTypeIdle), + string(ArchiveStatusTypeInProgress), + string(ArchiveStatusTypeNotConfigured), + } +} + +func (s *ArchiveStatusType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseArchiveStatusType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseArchiveStatusType(input string) (*ArchiveStatusType, error) { + vals := map[string]ArchiveStatusType{ + "canceled": ArchiveStatusTypeCanceled, + "cancelling": ArchiveStatusTypeCancelling, + "completed": ArchiveStatusTypeCompleted, + "fsscaninprogress": ArchiveStatusTypeFSScanInProgress, + "failed": ArchiveStatusTypeFailed, + "idle": ArchiveStatusTypeIdle, + "inprogress": ArchiveStatusTypeInProgress, + "notconfigured": ArchiveStatusTypeNotConfigured, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ArchiveStatusType(input) + return &out, nil +} + +type MaintenanceDayOfWeekType string + +const ( + MaintenanceDayOfWeekTypeFriday MaintenanceDayOfWeekType = "Friday" + MaintenanceDayOfWeekTypeMonday MaintenanceDayOfWeekType = "Monday" + MaintenanceDayOfWeekTypeSaturday MaintenanceDayOfWeekType = "Saturday" + MaintenanceDayOfWeekTypeSunday MaintenanceDayOfWeekType = "Sunday" + MaintenanceDayOfWeekTypeThursday MaintenanceDayOfWeekType = "Thursday" + MaintenanceDayOfWeekTypeTuesday MaintenanceDayOfWeekType = "Tuesday" + MaintenanceDayOfWeekTypeWednesday MaintenanceDayOfWeekType = "Wednesday" +) + +func PossibleValuesForMaintenanceDayOfWeekType() []string { + return []string{ + string(MaintenanceDayOfWeekTypeFriday), + string(MaintenanceDayOfWeekTypeMonday), + string(MaintenanceDayOfWeekTypeSaturday), + string(MaintenanceDayOfWeekTypeSunday), + string(MaintenanceDayOfWeekTypeThursday), + string(MaintenanceDayOfWeekTypeTuesday), + string(MaintenanceDayOfWeekTypeWednesday), + } +} + +func (s *MaintenanceDayOfWeekType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMaintenanceDayOfWeekType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMaintenanceDayOfWeekType(input string) (*MaintenanceDayOfWeekType, error) { + vals := map[string]MaintenanceDayOfWeekType{ + "friday": MaintenanceDayOfWeekTypeFriday, + "monday": MaintenanceDayOfWeekTypeMonday, + "saturday": MaintenanceDayOfWeekTypeSaturday, + "sunday": MaintenanceDayOfWeekTypeSunday, + "thursday": MaintenanceDayOfWeekTypeThursday, + "tuesday": MaintenanceDayOfWeekTypeTuesday, + "wednesday": MaintenanceDayOfWeekTypeWednesday, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MaintenanceDayOfWeekType(input) + return &out, nil +} diff --git a/resource-manager/storagecache/2024-03-01/amlfilesystems/id_amlfilesystem.go b/resource-manager/storagecache/2024-03-01/amlfilesystems/id_amlfilesystem.go new file mode 100644 index 00000000000..79bc2d6e34a --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/amlfilesystems/id_amlfilesystem.go @@ -0,0 +1,130 @@ +package amlfilesystems + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&AmlFilesystemId{}) +} + +var _ resourceids.ResourceId = &AmlFilesystemId{} + +// AmlFilesystemId is a struct representing the Resource ID for a Aml Filesystem +type AmlFilesystemId struct { + SubscriptionId string + ResourceGroupName string + AmlFilesystemName string +} + +// NewAmlFilesystemID returns a new AmlFilesystemId struct +func NewAmlFilesystemID(subscriptionId string, resourceGroupName string, amlFilesystemName string) AmlFilesystemId { + return AmlFilesystemId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + AmlFilesystemName: amlFilesystemName, + } +} + +// ParseAmlFilesystemID parses 'input' into a AmlFilesystemId +func ParseAmlFilesystemID(input string) (*AmlFilesystemId, error) { + parser := resourceids.NewParserFromResourceIdType(&AmlFilesystemId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AmlFilesystemId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAmlFilesystemIDInsensitively parses 'input' case-insensitively into a AmlFilesystemId +// note: this method should only be used for API response data and not user input +func ParseAmlFilesystemIDInsensitively(input string) (*AmlFilesystemId, error) { + parser := resourceids.NewParserFromResourceIdType(&AmlFilesystemId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AmlFilesystemId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AmlFilesystemId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.AmlFilesystemName, ok = input.Parsed["amlFilesystemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "amlFilesystemName", input) + } + + return nil +} + +// ValidateAmlFilesystemID checks that 'input' can be parsed as a Aml Filesystem ID +func ValidateAmlFilesystemID(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 := ParseAmlFilesystemID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Aml Filesystem ID +func (id AmlFilesystemId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.StorageCache/amlFilesystems/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.AmlFilesystemName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Aml Filesystem ID +func (id AmlFilesystemId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftStorageCache", "Microsoft.StorageCache", "Microsoft.StorageCache"), + resourceids.StaticSegment("staticAmlFilesystems", "amlFilesystems", "amlFilesystems"), + resourceids.UserSpecifiedSegment("amlFilesystemName", "amlFilesystemValue"), + } +} + +// String returns a human-readable description of this Aml Filesystem ID +func (id AmlFilesystemId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Aml Filesystem Name: %q", id.AmlFilesystemName), + } + return fmt.Sprintf("Aml Filesystem (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/storagecache/2024-03-01/amlfilesystems/id_amlfilesystem_test.go b/resource-manager/storagecache/2024-03-01/amlfilesystems/id_amlfilesystem_test.go new file mode 100644 index 00000000000..5f950f0d0d4 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/amlfilesystems/id_amlfilesystem_test.go @@ -0,0 +1,282 @@ +package amlfilesystems + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &AmlFilesystemId{} + +func TestNewAmlFilesystemID(t *testing.T) { + id := NewAmlFilesystemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "amlFilesystemValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.AmlFilesystemName != "amlFilesystemValue" { + t.Fatalf("Expected %q but got %q for Segment 'AmlFilesystemName'", id.AmlFilesystemName, "amlFilesystemValue") + } +} + +func TestFormatAmlFilesystemID(t *testing.T) { + actual := NewAmlFilesystemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "amlFilesystemValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/amlFilesystems/amlFilesystemValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAmlFilesystemID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AmlFilesystemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/amlFilesystems", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/amlFilesystems/amlFilesystemValue", + Expected: &AmlFilesystemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + AmlFilesystemName: "amlFilesystemValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/amlFilesystems/amlFilesystemValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAmlFilesystemID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", 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.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.AmlFilesystemName != v.Expected.AmlFilesystemName { + t.Fatalf("Expected %q but got %q for AmlFilesystemName", v.Expected.AmlFilesystemName, actual.AmlFilesystemName) + } + + } +} + +func TestParseAmlFilesystemIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AmlFilesystemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sToRaGeCaChE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/amlFilesystems", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sToRaGeCaChE/aMlFiLeSyStEmS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/amlFilesystems/amlFilesystemValue", + Expected: &AmlFilesystemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + AmlFilesystemName: "amlFilesystemValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/amlFilesystems/amlFilesystemValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sToRaGeCaChE/aMlFiLeSyStEmS/aMlFiLeSyStEmVaLuE", + Expected: &AmlFilesystemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + AmlFilesystemName: "aMlFiLeSyStEmVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sToRaGeCaChE/aMlFiLeSyStEmS/aMlFiLeSyStEmVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAmlFilesystemIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", 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.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.AmlFilesystemName != v.Expected.AmlFilesystemName { + t.Fatalf("Expected %q but got %q for AmlFilesystemName", v.Expected.AmlFilesystemName, actual.AmlFilesystemName) + } + + } +} + +func TestSegmentsForAmlFilesystemId(t *testing.T) { + segments := AmlFilesystemId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AmlFilesystemId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/storagecache/2024-03-01/amlfilesystems/method_archive.go b/resource-manager/storagecache/2024-03-01/amlfilesystems/method_archive.go new file mode 100644 index 00000000000..f4a1e33ff8a --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/amlfilesystems/method_archive.go @@ -0,0 +1,51 @@ +package amlfilesystems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ArchiveOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Archive ... +func (c AmlFilesystemsClient) Archive(ctx context.Context, id AmlFilesystemId, input AmlFilesystemArchiveInfo) (result ArchiveOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/archive", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/storagecache/2024-03-01/amlfilesystems/method_cancelarchive.go b/resource-manager/storagecache/2024-03-01/amlfilesystems/method_cancelarchive.go new file mode 100644 index 00000000000..fe88a916bad --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/amlfilesystems/method_cancelarchive.go @@ -0,0 +1,47 @@ +package amlfilesystems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CancelArchiveOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// CancelArchive ... +func (c AmlFilesystemsClient) CancelArchive(ctx context.Context, id AmlFilesystemId) (result CancelArchiveOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/cancelArchive", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/storagecache/2024-03-01/amlfilesystems/method_checkamlfssubnets.go b/resource-manager/storagecache/2024-03-01/amlfilesystems/method_checkamlfssubnets.go new file mode 100644 index 00000000000..318854bb400 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/amlfilesystems/method_checkamlfssubnets.go @@ -0,0 +1,52 @@ +package amlfilesystems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckAmlFSSubnetsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// CheckAmlFSSubnets ... +func (c AmlFilesystemsClient) CheckAmlFSSubnets(ctx context.Context, id commonids.SubscriptionId, input AmlFilesystemSubnetInfo) (result CheckAmlFSSubnetsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.StorageCache/checkAmlFSSubnets", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/storagecache/2024-03-01/amlfilesystems/method_createorupdate.go b/resource-manager/storagecache/2024-03-01/amlfilesystems/method_createorupdate.go new file mode 100644 index 00000000000..5f576629b71 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/amlfilesystems/method_createorupdate.go @@ -0,0 +1,75 @@ +package amlfilesystems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// 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 { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AmlFilesystem +} + +// CreateOrUpdate ... +func (c AmlFilesystemsClient) CreateOrUpdate(ctx context.Context, id AmlFilesystemId, input AmlFilesystem) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c AmlFilesystemsClient) CreateOrUpdateThenPoll(ctx context.Context, id AmlFilesystemId, input AmlFilesystem) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/storagecache/2024-03-01/amlfilesystems/method_delete.go b/resource-manager/storagecache/2024-03-01/amlfilesystems/method_delete.go new file mode 100644 index 00000000000..32417bbc60a --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/amlfilesystems/method_delete.go @@ -0,0 +1,71 @@ +package amlfilesystems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// 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 { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c AmlFilesystemsClient) Delete(ctx context.Context, id AmlFilesystemId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c AmlFilesystemsClient) DeleteThenPoll(ctx context.Context, id AmlFilesystemId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/storagecache/2024-03-01/amlfilesystems/method_get.go b/resource-manager/storagecache/2024-03-01/amlfilesystems/method_get.go new file mode 100644 index 00000000000..345b54c274b --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/amlfilesystems/method_get.go @@ -0,0 +1,54 @@ +package amlfilesystems + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// 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 + OData *odata.OData + Model *AmlFilesystem +} + +// Get ... +func (c AmlFilesystemsClient) Get(ctx context.Context, id AmlFilesystemId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AmlFilesystem + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/storagecache/2024-03-01/amlfilesystems/method_getrequiredamlfssubnetssize.go b/resource-manager/storagecache/2024-03-01/amlfilesystems/method_getrequiredamlfssubnetssize.go new file mode 100644 index 00000000000..c9447ea07a4 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/amlfilesystems/method_getrequiredamlfssubnetssize.go @@ -0,0 +1,60 @@ +package amlfilesystems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetRequiredAmlFSSubnetsSizeOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RequiredAmlFilesystemSubnetsSize +} + +// GetRequiredAmlFSSubnetsSize ... +func (c AmlFilesystemsClient) GetRequiredAmlFSSubnetsSize(ctx context.Context, id commonids.SubscriptionId, input RequiredAmlFilesystemSubnetsSizeInfo) (result GetRequiredAmlFSSubnetsSizeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.StorageCache/getRequiredAmlFSSubnetsSize", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RequiredAmlFilesystemSubnetsSize + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/storagecache/2024-03-01/amlfilesystems/method_list.go b/resource-manager/storagecache/2024-03-01/amlfilesystems/method_list.go new file mode 100644 index 00000000000..976154dce41 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/amlfilesystems/method_list.go @@ -0,0 +1,92 @@ +package amlfilesystems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// 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 + OData *odata.OData + Model *[]AmlFilesystem +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []AmlFilesystem +} + +// List ... +func (c AmlFilesystemsClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.StorageCache/amlFilesystems", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AmlFilesystem `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c AmlFilesystemsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, AmlFilesystemOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AmlFilesystemsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate AmlFilesystemOperationPredicate) (result ListCompleteResult, err error) { + items := make([]AmlFilesystem, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/storagecache/2024-03-01/amlfilesystems/method_listbyresourcegroup.go b/resource-manager/storagecache/2024-03-01/amlfilesystems/method_listbyresourcegroup.go new file mode 100644 index 00000000000..0089a8f835b --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/amlfilesystems/method_listbyresourcegroup.go @@ -0,0 +1,92 @@ +package amlfilesystems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AmlFilesystem +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []AmlFilesystem +} + +// ListByResourceGroup ... +func (c AmlFilesystemsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.StorageCache/amlFilesystems", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AmlFilesystem `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c AmlFilesystemsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, AmlFilesystemOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AmlFilesystemsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate AmlFilesystemOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]AmlFilesystem, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/storagecache/2024-03-01/amlfilesystems/method_update.go b/resource-manager/storagecache/2024-03-01/amlfilesystems/method_update.go new file mode 100644 index 00000000000..6130559752f --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/amlfilesystems/method_update.go @@ -0,0 +1,75 @@ +package amlfilesystems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AmlFilesystem +} + +// Update ... +func (c AmlFilesystemsClient) Update(ctx context.Context, id AmlFilesystemId, input AmlFilesystemUpdate) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c AmlFilesystemsClient) UpdateThenPoll(ctx context.Context, id AmlFilesystemId, input AmlFilesystemUpdate) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystem.go b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystem.go new file mode 100644 index 00000000000..532867a88d3 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystem.go @@ -0,0 +1,23 @@ +package amlfilesystems + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AmlFilesystem struct { + Id *string `json:"id,omitempty"` + Identity *identity.UserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *AmlFilesystemProperties `json:"properties,omitempty"` + Sku *SkuName `json:"sku,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystemarchive.go b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystemarchive.go new file mode 100644 index 00000000000..f2a11ab852c --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystemarchive.go @@ -0,0 +1,9 @@ +package amlfilesystems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AmlFilesystemArchive struct { + FilesystemPath *string `json:"filesystemPath,omitempty"` + Status *AmlFilesystemArchiveStatus `json:"status,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystemarchiveinfo.go b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystemarchiveinfo.go new file mode 100644 index 00000000000..10771b9ab5f --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystemarchiveinfo.go @@ -0,0 +1,8 @@ +package amlfilesystems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AmlFilesystemArchiveInfo struct { + FilesystemPath *string `json:"filesystemPath,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystemarchivestatus.go b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystemarchivestatus.go new file mode 100644 index 00000000000..2f31f82bad6 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystemarchivestatus.go @@ -0,0 +1,43 @@ +package amlfilesystems + +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 AmlFilesystemArchiveStatus struct { + ErrorCode *string `json:"errorCode,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + LastCompletionTime *string `json:"lastCompletionTime,omitempty"` + LastStartedTime *string `json:"lastStartedTime,omitempty"` + PercentComplete *int64 `json:"percentComplete,omitempty"` + State *ArchiveStatusType `json:"state,omitempty"` +} + +func (o *AmlFilesystemArchiveStatus) GetLastCompletionTimeAsTime() (*time.Time, error) { + if o.LastCompletionTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastCompletionTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AmlFilesystemArchiveStatus) SetLastCompletionTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastCompletionTime = &formatted +} + +func (o *AmlFilesystemArchiveStatus) GetLastStartedTimeAsTime() (*time.Time, error) { + if o.LastStartedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastStartedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AmlFilesystemArchiveStatus) SetLastStartedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastStartedTime = &formatted +} diff --git a/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystemclientinfo.go b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystemclientinfo.go new file mode 100644 index 00000000000..b25e1e6e870 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystemclientinfo.go @@ -0,0 +1,11 @@ +package amlfilesystems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AmlFilesystemClientInfo struct { + ContainerStorageInterface *AmlFilesystemContainerStorageInterface `json:"containerStorageInterface,omitempty"` + LustreVersion *string `json:"lustreVersion,omitempty"` + MgsAddress *string `json:"mgsAddress,omitempty"` + MountCommand *string `json:"mountCommand,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystemcontainerstorageinterface.go b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystemcontainerstorageinterface.go new file mode 100644 index 00000000000..830b43de8b7 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystemcontainerstorageinterface.go @@ -0,0 +1,10 @@ +package amlfilesystems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AmlFilesystemContainerStorageInterface struct { + PersistentVolume *string `json:"persistentVolume,omitempty"` + PersistentVolumeClaim *string `json:"persistentVolumeClaim,omitempty"` + StorageClass *string `json:"storageClass,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystemencryptionsettings.go b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystemencryptionsettings.go new file mode 100644 index 00000000000..352e6ca1769 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystemencryptionsettings.go @@ -0,0 +1,8 @@ +package amlfilesystems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AmlFilesystemEncryptionSettings struct { + KeyEncryptionKey *KeyVaultKeyReference `json:"keyEncryptionKey,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystemhealth.go b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystemhealth.go new file mode 100644 index 00000000000..c51b007bc18 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystemhealth.go @@ -0,0 +1,10 @@ +package amlfilesystems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AmlFilesystemHealth struct { + State *AmlFilesystemHealthStateType `json:"state,omitempty"` + StatusCode *string `json:"statusCode,omitempty"` + StatusDescription *string `json:"statusDescription,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystemhsmsettings.go b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystemhsmsettings.go new file mode 100644 index 00000000000..2ed9f851d3b --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystemhsmsettings.go @@ -0,0 +1,11 @@ +package amlfilesystems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AmlFilesystemHsmSettings struct { + Container string `json:"container"` + ImportPrefix *string `json:"importPrefix,omitempty"` + ImportPrefixesInitial *[]string `json:"importPrefixesInitial,omitempty"` + LoggingContainer string `json:"loggingContainer"` +} diff --git a/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystemproperties.go b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystemproperties.go new file mode 100644 index 00000000000..43ec822f31a --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystemproperties.go @@ -0,0 +1,17 @@ +package amlfilesystems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AmlFilesystemProperties struct { + ClientInfo *AmlFilesystemClientInfo `json:"clientInfo,omitempty"` + EncryptionSettings *AmlFilesystemEncryptionSettings `json:"encryptionSettings,omitempty"` + FilesystemSubnet string `json:"filesystemSubnet"` + Health *AmlFilesystemHealth `json:"health,omitempty"` + Hsm *AmlFilesystemPropertiesHsm `json:"hsm,omitempty"` + MaintenanceWindow AmlFilesystemPropertiesMaintenanceWindow `json:"maintenanceWindow"` + ProvisioningState *AmlFilesystemProvisioningStateType `json:"provisioningState,omitempty"` + RootSquashSettings *AmlFilesystemRootSquashSettings `json:"rootSquashSettings,omitempty"` + StorageCapacityTiB float64 `json:"storageCapacityTiB"` + ThroughputProvisionedMBps *int64 `json:"throughputProvisionedMBps,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystempropertieshsm.go b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystempropertieshsm.go new file mode 100644 index 00000000000..c6c4f71e602 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystempropertieshsm.go @@ -0,0 +1,9 @@ +package amlfilesystems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AmlFilesystemPropertiesHsm struct { + ArchiveStatus *[]AmlFilesystemArchive `json:"archiveStatus,omitempty"` + Settings *AmlFilesystemHsmSettings `json:"settings,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystempropertiesmaintenancewindow.go b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystempropertiesmaintenancewindow.go new file mode 100644 index 00000000000..7771eb96f6e --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystempropertiesmaintenancewindow.go @@ -0,0 +1,9 @@ +package amlfilesystems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AmlFilesystemPropertiesMaintenanceWindow struct { + DayOfWeek *MaintenanceDayOfWeekType `json:"dayOfWeek,omitempty"` + TimeOfDayUTC *string `json:"timeOfDayUTC,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystemrootsquashsettings.go b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystemrootsquashsettings.go new file mode 100644 index 00000000000..03fd1d27fc4 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystemrootsquashsettings.go @@ -0,0 +1,12 @@ +package amlfilesystems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AmlFilesystemRootSquashSettings struct { + Mode *AmlFilesystemSquashMode `json:"mode,omitempty"` + NoSquashNidLists *string `json:"noSquashNidLists,omitempty"` + SquashGID *int64 `json:"squashGID,omitempty"` + SquashUID *int64 `json:"squashUID,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystemsubnetinfo.go b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystemsubnetinfo.go new file mode 100644 index 00000000000..87d82b6edba --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystemsubnetinfo.go @@ -0,0 +1,11 @@ +package amlfilesystems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AmlFilesystemSubnetInfo struct { + FilesystemSubnet *string `json:"filesystemSubnet,omitempty"` + Location *string `json:"location,omitempty"` + Sku *SkuName `json:"sku,omitempty"` + StorageCapacityTiB *float64 `json:"storageCapacityTiB,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystemupdate.go b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystemupdate.go new file mode 100644 index 00000000000..41b072bc172 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystemupdate.go @@ -0,0 +1,9 @@ +package amlfilesystems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AmlFilesystemUpdate struct { + Properties *AmlFilesystemUpdateProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystemupdateproperties.go b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystemupdateproperties.go new file mode 100644 index 00000000000..eb3a7daf075 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystemupdateproperties.go @@ -0,0 +1,10 @@ +package amlfilesystems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AmlFilesystemUpdateProperties struct { + EncryptionSettings *AmlFilesystemEncryptionSettings `json:"encryptionSettings,omitempty"` + MaintenanceWindow *AmlFilesystemUpdatePropertiesMaintenanceWindow `json:"maintenanceWindow,omitempty"` + RootSquashSettings *AmlFilesystemRootSquashSettings `json:"rootSquashSettings,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystemupdatepropertiesmaintenancewindow.go b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystemupdatepropertiesmaintenancewindow.go new file mode 100644 index 00000000000..3a396fef32f --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_amlfilesystemupdatepropertiesmaintenancewindow.go @@ -0,0 +1,9 @@ +package amlfilesystems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AmlFilesystemUpdatePropertiesMaintenanceWindow struct { + DayOfWeek *MaintenanceDayOfWeekType `json:"dayOfWeek,omitempty"` + TimeOfDayUTC *string `json:"timeOfDayUTC,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/amlfilesystems/model_keyvaultkeyreference.go b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_keyvaultkeyreference.go new file mode 100644 index 00000000000..475466a877d --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_keyvaultkeyreference.go @@ -0,0 +1,9 @@ +package amlfilesystems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyVaultKeyReference struct { + KeyUrl string `json:"keyUrl"` + SourceVault KeyVaultKeyReferenceSourceVault `json:"sourceVault"` +} diff --git a/resource-manager/storagecache/2024-03-01/amlfilesystems/model_keyvaultkeyreferencesourcevault.go b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_keyvaultkeyreferencesourcevault.go new file mode 100644 index 00000000000..9c8cbe1467e --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_keyvaultkeyreferencesourcevault.go @@ -0,0 +1,8 @@ +package amlfilesystems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyVaultKeyReferenceSourceVault struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/amlfilesystems/model_requiredamlfilesystemsubnetssize.go b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_requiredamlfilesystemsubnetssize.go new file mode 100644 index 00000000000..86b2a2dd0df --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_requiredamlfilesystemsubnetssize.go @@ -0,0 +1,8 @@ +package amlfilesystems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RequiredAmlFilesystemSubnetsSize struct { + FilesystemSubnetSize *int64 `json:"filesystemSubnetSize,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/amlfilesystems/model_requiredamlfilesystemsubnetssizeinfo.go b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_requiredamlfilesystemsubnetssizeinfo.go new file mode 100644 index 00000000000..d7e99a9de98 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_requiredamlfilesystemsubnetssizeinfo.go @@ -0,0 +1,9 @@ +package amlfilesystems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RequiredAmlFilesystemSubnetsSizeInfo struct { + Sku *SkuName `json:"sku,omitempty"` + StorageCapacityTiB *float64 `json:"storageCapacityTiB,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/amlfilesystems/model_skuname.go b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_skuname.go new file mode 100644 index 00000000000..cbca7bfd94f --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/amlfilesystems/model_skuname.go @@ -0,0 +1,8 @@ +package amlfilesystems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SkuName struct { + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/amlfilesystems/predicates.go b/resource-manager/storagecache/2024-03-01/amlfilesystems/predicates.go new file mode 100644 index 00000000000..945d416104a --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/amlfilesystems/predicates.go @@ -0,0 +1,32 @@ +package amlfilesystems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AmlFilesystemOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p AmlFilesystemOperationPredicate) Matches(input AmlFilesystem) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + 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/resource-manager/storagecache/2024-03-01/amlfilesystems/version.go b/resource-manager/storagecache/2024-03-01/amlfilesystems/version.go new file mode 100644 index 00000000000..29fcec0d9a0 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/amlfilesystems/version.go @@ -0,0 +1,12 @@ +package amlfilesystems + +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 = "2024-03-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/amlfilesystems/%s", defaultApiVersion) +} diff --git a/resource-manager/storagecache/2024-03-01/ascusages/README.md b/resource-manager/storagecache/2024-03-01/ascusages/README.md new file mode 100644 index 00000000000..16a3838c444 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/ascusages/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/storagecache/2024-03-01/ascusages` Documentation + +The `ascusages` SDK allows for interaction with the Azure Resource Manager Service `storagecache` (API Version `2024-03-01`). + +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/storagecache/2024-03-01/ascusages" +``` + + +### Client Initialization + +```go +client := ascusages.NewAscUsagesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AscUsagesClient.List` + +```go +ctx := context.TODO() +id := ascusages.NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/storagecache/2024-03-01/ascusages/client.go b/resource-manager/storagecache/2024-03-01/ascusages/client.go new file mode 100644 index 00000000000..b1d28a89834 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/ascusages/client.go @@ -0,0 +1,26 @@ +package ascusages + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AscUsagesClient struct { + Client *resourcemanager.Client +} + +func NewAscUsagesClientWithBaseURI(sdkApi sdkEnv.Api) (*AscUsagesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "ascusages", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AscUsagesClient: %+v", err) + } + + return &AscUsagesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/storagecache/2024-03-01/ascusages/id_location.go b/resource-manager/storagecache/2024-03-01/ascusages/id_location.go new file mode 100644 index 00000000000..96db2d03aee --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/ascusages/id_location.go @@ -0,0 +1,121 @@ +package ascusages + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(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 := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.StorageCache/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location ID +func (id LocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftStorageCache", "Microsoft.StorageCache", "Microsoft.StorageCache"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationValue"), + } +} + +// String returns a human-readable description of this Location ID +func (id LocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/storagecache/2024-03-01/ascusages/id_location_test.go b/resource-manager/storagecache/2024-03-01/ascusages/id_location_test.go new file mode 100644 index 00000000000..5a5b93944e9 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/ascusages/id_location_test.go @@ -0,0 +1,237 @@ +package ascusages + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LocationId{} + +func TestNewLocationID(t *testing.T) { + id := NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationValue" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationValue") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.StorageCache/locations/locationValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.StorageCache", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.StorageCache/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.StorageCache/locations/locationValue", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.StorageCache/locations/locationValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", 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.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.StorageCache", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sToRaGeCaChE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.StorageCache/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sToRaGeCaChE/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.StorageCache/locations/locationValue", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.StorageCache/locations/locationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sToRaGeCaChE/lOcAtIoNs/lOcAtIoNvAlUe", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sToRaGeCaChE/lOcAtIoNs/lOcAtIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", 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.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForLocationId(t *testing.T) { + segments := LocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/storagecache/2024-03-01/ascusages/method_list.go b/resource-manager/storagecache/2024-03-01/ascusages/method_list.go new file mode 100644 index 00000000000..491980cb5ef --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/ascusages/method_list.go @@ -0,0 +1,91 @@ +package ascusages + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// 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 + OData *odata.OData + Model *[]ResourceUsage +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ResourceUsage +} + +// List ... +func (c AscUsagesClient) List(ctx context.Context, id LocationId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/usages", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ResourceUsage `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c AscUsagesClient) ListComplete(ctx context.Context, id LocationId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ResourceUsageOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AscUsagesClient) ListCompleteMatchingPredicate(ctx context.Context, id LocationId, predicate ResourceUsageOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ResourceUsage, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/storagecache/2024-03-01/ascusages/model_resourceusage.go b/resource-manager/storagecache/2024-03-01/ascusages/model_resourceusage.go new file mode 100644 index 00000000000..e8df5283349 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/ascusages/model_resourceusage.go @@ -0,0 +1,11 @@ +package ascusages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceUsage struct { + CurrentValue *int64 `json:"currentValue,omitempty"` + Limit *int64 `json:"limit,omitempty"` + Name *ResourceUsageName `json:"name,omitempty"` + Unit *string `json:"unit,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/ascusages/model_resourceusagename.go b/resource-manager/storagecache/2024-03-01/ascusages/model_resourceusagename.go new file mode 100644 index 00000000000..efd3a470bf2 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/ascusages/model_resourceusagename.go @@ -0,0 +1,9 @@ +package ascusages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceUsageName struct { + LocalizedValue *string `json:"localizedValue,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/ascusages/predicates.go b/resource-manager/storagecache/2024-03-01/ascusages/predicates.go new file mode 100644 index 00000000000..d17d6ebf577 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/ascusages/predicates.go @@ -0,0 +1,27 @@ +package ascusages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceUsageOperationPredicate struct { + CurrentValue *int64 + Limit *int64 + Unit *string +} + +func (p ResourceUsageOperationPredicate) Matches(input ResourceUsage) bool { + + if p.CurrentValue != nil && (input.CurrentValue == nil || *p.CurrentValue != *input.CurrentValue) { + return false + } + + if p.Limit != nil && (input.Limit == nil || *p.Limit != *input.Limit) { + return false + } + + if p.Unit != nil && (input.Unit == nil || *p.Unit != *input.Unit) { + return false + } + + return true +} diff --git a/resource-manager/storagecache/2024-03-01/ascusages/version.go b/resource-manager/storagecache/2024-03-01/ascusages/version.go new file mode 100644 index 00000000000..5e1e0c3f539 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/ascusages/version.go @@ -0,0 +1,12 @@ +package ascusages + +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 = "2024-03-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/ascusages/%s", defaultApiVersion) +} diff --git a/resource-manager/storagecache/2024-03-01/caches/README.md b/resource-manager/storagecache/2024-03-01/caches/README.md new file mode 100644 index 00000000000..8778e845bf5 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/README.md @@ -0,0 +1,258 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/storagecache/2024-03-01/caches` Documentation + +The `caches` SDK allows for interaction with the Azure Resource Manager Service `storagecache` (API Version `2024-03-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/storagecache/2024-03-01/caches" +``` + + +### Client Initialization + +```go +client := caches.NewCachesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CachesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := caches.NewCacheID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cacheValue") + +payload := caches.Cache{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CachesClient.DebugInfo` + +```go +ctx := context.TODO() +id := caches.NewCacheID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cacheValue") + +if err := client.DebugInfoThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CachesClient.Delete` + +```go +ctx := context.TODO() +id := caches.NewCacheID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cacheValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CachesClient.Flush` + +```go +ctx := context.TODO() +id := caches.NewCacheID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cacheValue") + +if err := client.FlushThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CachesClient.Get` + +```go +ctx := context.TODO() +id := caches.NewCacheID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cacheValue") + +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: `CachesClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `CachesClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `CachesClient.PausePrimingJob` + +```go +ctx := context.TODO() +id := caches.NewCacheID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cacheValue") + +payload := caches.PrimingJobIdParameter{ + // ... +} + + +if err := client.PausePrimingJobThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CachesClient.ResumePrimingJob` + +```go +ctx := context.TODO() +id := caches.NewCacheID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cacheValue") + +payload := caches.PrimingJobIdParameter{ + // ... +} + + +if err := client.ResumePrimingJobThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CachesClient.SpaceAllocation` + +```go +ctx := context.TODO() +id := caches.NewCacheID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cacheValue") +var payload []StorageTargetSpaceAllocation + +if err := client.SpaceAllocationThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CachesClient.Start` + +```go +ctx := context.TODO() +id := caches.NewCacheID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cacheValue") + +if err := client.StartThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CachesClient.StartPrimingJob` + +```go +ctx := context.TODO() +id := caches.NewCacheID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cacheValue") + +payload := caches.PrimingJob{ + // ... +} + + +if err := client.StartPrimingJobThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CachesClient.Stop` + +```go +ctx := context.TODO() +id := caches.NewCacheID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cacheValue") + +if err := client.StopThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CachesClient.StopPrimingJob` + +```go +ctx := context.TODO() +id := caches.NewCacheID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cacheValue") + +payload := caches.PrimingJobIdParameter{ + // ... +} + + +if err := client.StopPrimingJobThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CachesClient.Update` + +```go +ctx := context.TODO() +id := caches.NewCacheID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cacheValue") + +payload := caches.Cache{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CachesClient.UpgradeFirmware` + +```go +ctx := context.TODO() +id := caches.NewCacheID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cacheValue") + +if err := client.UpgradeFirmwareThenPoll(ctx, id); err != nil { + // handle the error +} +``` diff --git a/resource-manager/storagecache/2024-03-01/caches/client.go b/resource-manager/storagecache/2024-03-01/caches/client.go new file mode 100644 index 00000000000..0502f89bac3 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/client.go @@ -0,0 +1,26 @@ +package caches + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CachesClient struct { + Client *resourcemanager.Client +} + +func NewCachesClientWithBaseURI(sdkApi sdkEnv.Api) (*CachesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "caches", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CachesClient: %+v", err) + } + + return &CachesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/storagecache/2024-03-01/caches/constants.go b/resource-manager/storagecache/2024-03-01/caches/constants.go new file mode 100644 index 00000000000..a9e0ce00a29 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/constants.go @@ -0,0 +1,445 @@ +package caches + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DomainJoinedType string + +const ( + DomainJoinedTypeError DomainJoinedType = "Error" + DomainJoinedTypeNo DomainJoinedType = "No" + DomainJoinedTypeYes DomainJoinedType = "Yes" +) + +func PossibleValuesForDomainJoinedType() []string { + return []string{ + string(DomainJoinedTypeError), + string(DomainJoinedTypeNo), + string(DomainJoinedTypeYes), + } +} + +func (s *DomainJoinedType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDomainJoinedType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDomainJoinedType(input string) (*DomainJoinedType, error) { + vals := map[string]DomainJoinedType{ + "error": DomainJoinedTypeError, + "no": DomainJoinedTypeNo, + "yes": DomainJoinedTypeYes, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DomainJoinedType(input) + return &out, nil +} + +type FirmwareStatusType string + +const ( + FirmwareStatusTypeAvailable FirmwareStatusType = "available" + FirmwareStatusTypeUnavailable FirmwareStatusType = "unavailable" +) + +func PossibleValuesForFirmwareStatusType() []string { + return []string{ + string(FirmwareStatusTypeAvailable), + string(FirmwareStatusTypeUnavailable), + } +} + +func (s *FirmwareStatusType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFirmwareStatusType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFirmwareStatusType(input string) (*FirmwareStatusType, error) { + vals := map[string]FirmwareStatusType{ + "available": FirmwareStatusTypeAvailable, + "unavailable": FirmwareStatusTypeUnavailable, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FirmwareStatusType(input) + return &out, nil +} + +type HealthStateType string + +const ( + HealthStateTypeDegraded HealthStateType = "Degraded" + HealthStateTypeDown HealthStateType = "Down" + HealthStateTypeFlushing HealthStateType = "Flushing" + HealthStateTypeHealthy HealthStateType = "Healthy" + HealthStateTypeStartFailed HealthStateType = "StartFailed" + HealthStateTypeStopped HealthStateType = "Stopped" + HealthStateTypeStopping HealthStateType = "Stopping" + HealthStateTypeTransitioning HealthStateType = "Transitioning" + HealthStateTypeUnknown HealthStateType = "Unknown" + HealthStateTypeUpgradeFailed HealthStateType = "UpgradeFailed" + HealthStateTypeUpgrading HealthStateType = "Upgrading" + HealthStateTypeWaitingForKey HealthStateType = "WaitingForKey" +) + +func PossibleValuesForHealthStateType() []string { + return []string{ + string(HealthStateTypeDegraded), + string(HealthStateTypeDown), + string(HealthStateTypeFlushing), + string(HealthStateTypeHealthy), + string(HealthStateTypeStartFailed), + string(HealthStateTypeStopped), + string(HealthStateTypeStopping), + string(HealthStateTypeTransitioning), + string(HealthStateTypeUnknown), + string(HealthStateTypeUpgradeFailed), + string(HealthStateTypeUpgrading), + string(HealthStateTypeWaitingForKey), + } +} + +func (s *HealthStateType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthStateType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthStateType(input string) (*HealthStateType, error) { + vals := map[string]HealthStateType{ + "degraded": HealthStateTypeDegraded, + "down": HealthStateTypeDown, + "flushing": HealthStateTypeFlushing, + "healthy": HealthStateTypeHealthy, + "startfailed": HealthStateTypeStartFailed, + "stopped": HealthStateTypeStopped, + "stopping": HealthStateTypeStopping, + "transitioning": HealthStateTypeTransitioning, + "unknown": HealthStateTypeUnknown, + "upgradefailed": HealthStateTypeUpgradeFailed, + "upgrading": HealthStateTypeUpgrading, + "waitingforkey": HealthStateTypeWaitingForKey, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthStateType(input) + return &out, nil +} + +type NfsAccessRuleAccess string + +const ( + NfsAccessRuleAccessNo NfsAccessRuleAccess = "no" + NfsAccessRuleAccessRo NfsAccessRuleAccess = "ro" + NfsAccessRuleAccessRw NfsAccessRuleAccess = "rw" +) + +func PossibleValuesForNfsAccessRuleAccess() []string { + return []string{ + string(NfsAccessRuleAccessNo), + string(NfsAccessRuleAccessRo), + string(NfsAccessRuleAccessRw), + } +} + +func (s *NfsAccessRuleAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNfsAccessRuleAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNfsAccessRuleAccess(input string) (*NfsAccessRuleAccess, error) { + vals := map[string]NfsAccessRuleAccess{ + "no": NfsAccessRuleAccessNo, + "ro": NfsAccessRuleAccessRo, + "rw": NfsAccessRuleAccessRw, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NfsAccessRuleAccess(input) + return &out, nil +} + +type NfsAccessRuleScope string + +const ( + NfsAccessRuleScopeDefault NfsAccessRuleScope = "default" + NfsAccessRuleScopeHost NfsAccessRuleScope = "host" + NfsAccessRuleScopeNetwork NfsAccessRuleScope = "network" +) + +func PossibleValuesForNfsAccessRuleScope() []string { + return []string{ + string(NfsAccessRuleScopeDefault), + string(NfsAccessRuleScopeHost), + string(NfsAccessRuleScopeNetwork), + } +} + +func (s *NfsAccessRuleScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNfsAccessRuleScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNfsAccessRuleScope(input string) (*NfsAccessRuleScope, error) { + vals := map[string]NfsAccessRuleScope{ + "default": NfsAccessRuleScopeDefault, + "host": NfsAccessRuleScopeHost, + "network": NfsAccessRuleScopeNetwork, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NfsAccessRuleScope(input) + return &out, nil +} + +type PrimingJobState string + +const ( + PrimingJobStateComplete PrimingJobState = "Complete" + PrimingJobStatePaused PrimingJobState = "Paused" + PrimingJobStateQueued PrimingJobState = "Queued" + PrimingJobStateRunning PrimingJobState = "Running" +) + +func PossibleValuesForPrimingJobState() []string { + return []string{ + string(PrimingJobStateComplete), + string(PrimingJobStatePaused), + string(PrimingJobStateQueued), + string(PrimingJobStateRunning), + } +} + +func (s *PrimingJobState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrimingJobState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrimingJobState(input string) (*PrimingJobState, error) { + vals := map[string]PrimingJobState{ + "complete": PrimingJobStateComplete, + "paused": PrimingJobStatePaused, + "queued": PrimingJobStateQueued, + "running": PrimingJobStateRunning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrimingJobState(input) + return &out, nil +} + +type ProvisioningStateType string + +const ( + ProvisioningStateTypeCanceled ProvisioningStateType = "Canceled" + ProvisioningStateTypeCreating ProvisioningStateType = "Creating" + ProvisioningStateTypeDeleting ProvisioningStateType = "Deleting" + ProvisioningStateTypeFailed ProvisioningStateType = "Failed" + ProvisioningStateTypeSucceeded ProvisioningStateType = "Succeeded" + ProvisioningStateTypeUpdating ProvisioningStateType = "Updating" +) + +func PossibleValuesForProvisioningStateType() []string { + return []string{ + string(ProvisioningStateTypeCanceled), + string(ProvisioningStateTypeCreating), + string(ProvisioningStateTypeDeleting), + string(ProvisioningStateTypeFailed), + string(ProvisioningStateTypeSucceeded), + string(ProvisioningStateTypeUpdating), + } +} + +func (s *ProvisioningStateType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningStateType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningStateType(input string) (*ProvisioningStateType, error) { + vals := map[string]ProvisioningStateType{ + "canceled": ProvisioningStateTypeCanceled, + "creating": ProvisioningStateTypeCreating, + "deleting": ProvisioningStateTypeDeleting, + "failed": ProvisioningStateTypeFailed, + "succeeded": ProvisioningStateTypeSucceeded, + "updating": ProvisioningStateTypeUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningStateType(input) + return &out, nil +} + +type UsernameDownloadedType string + +const ( + UsernameDownloadedTypeError UsernameDownloadedType = "Error" + UsernameDownloadedTypeNo UsernameDownloadedType = "No" + UsernameDownloadedTypeYes UsernameDownloadedType = "Yes" +) + +func PossibleValuesForUsernameDownloadedType() []string { + return []string{ + string(UsernameDownloadedTypeError), + string(UsernameDownloadedTypeNo), + string(UsernameDownloadedTypeYes), + } +} + +func (s *UsernameDownloadedType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUsernameDownloadedType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUsernameDownloadedType(input string) (*UsernameDownloadedType, error) { + vals := map[string]UsernameDownloadedType{ + "error": UsernameDownloadedTypeError, + "no": UsernameDownloadedTypeNo, + "yes": UsernameDownloadedTypeYes, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UsernameDownloadedType(input) + return &out, nil +} + +type UsernameSource string + +const ( + UsernameSourceAD UsernameSource = "AD" + UsernameSourceFile UsernameSource = "File" + UsernameSourceLDAP UsernameSource = "LDAP" + UsernameSourceNone UsernameSource = "None" +) + +func PossibleValuesForUsernameSource() []string { + return []string{ + string(UsernameSourceAD), + string(UsernameSourceFile), + string(UsernameSourceLDAP), + string(UsernameSourceNone), + } +} + +func (s *UsernameSource) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUsernameSource(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUsernameSource(input string) (*UsernameSource, error) { + vals := map[string]UsernameSource{ + "ad": UsernameSourceAD, + "file": UsernameSourceFile, + "ldap": UsernameSourceLDAP, + "none": UsernameSourceNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UsernameSource(input) + return &out, nil +} diff --git a/resource-manager/storagecache/2024-03-01/caches/id_cache.go b/resource-manager/storagecache/2024-03-01/caches/id_cache.go new file mode 100644 index 00000000000..0ded0974f33 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/id_cache.go @@ -0,0 +1,130 @@ +package caches + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CacheId{}) +} + +var _ resourceids.ResourceId = &CacheId{} + +// CacheId is a struct representing the Resource ID for a Cache +type CacheId struct { + SubscriptionId string + ResourceGroupName string + CacheName string +} + +// NewCacheID returns a new CacheId struct +func NewCacheID(subscriptionId string, resourceGroupName string, cacheName string) CacheId { + return CacheId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CacheName: cacheName, + } +} + +// ParseCacheID parses 'input' into a CacheId +func ParseCacheID(input string) (*CacheId, error) { + parser := resourceids.NewParserFromResourceIdType(&CacheId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CacheId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCacheIDInsensitively parses 'input' case-insensitively into a CacheId +// note: this method should only be used for API response data and not user input +func ParseCacheIDInsensitively(input string) (*CacheId, error) { + parser := resourceids.NewParserFromResourceIdType(&CacheId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CacheId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CacheId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CacheName, ok = input.Parsed["cacheName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "cacheName", input) + } + + return nil +} + +// ValidateCacheID checks that 'input' can be parsed as a Cache ID +func ValidateCacheID(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 := ParseCacheID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Cache ID +func (id CacheId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.StorageCache/caches/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CacheName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Cache ID +func (id CacheId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftStorageCache", "Microsoft.StorageCache", "Microsoft.StorageCache"), + resourceids.StaticSegment("staticCaches", "caches", "caches"), + resourceids.UserSpecifiedSegment("cacheName", "cacheValue"), + } +} + +// String returns a human-readable description of this Cache ID +func (id CacheId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cache Name: %q", id.CacheName), + } + return fmt.Sprintf("Cache (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/storagecache/2024-03-01/caches/id_cache_test.go b/resource-manager/storagecache/2024-03-01/caches/id_cache_test.go new file mode 100644 index 00000000000..ddbd9c0fd89 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/id_cache_test.go @@ -0,0 +1,282 @@ +package caches + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &CacheId{} + +func TestNewCacheID(t *testing.T) { + id := NewCacheID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cacheValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.CacheName != "cacheValue" { + t.Fatalf("Expected %q but got %q for Segment 'CacheName'", id.CacheName, "cacheValue") + } +} + +func TestFormatCacheID(t *testing.T) { + actual := NewCacheID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cacheValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/caches/cacheValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCacheID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CacheId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/caches", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/caches/cacheValue", + Expected: &CacheId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CacheName: "cacheValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/caches/cacheValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCacheID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", 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.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CacheName != v.Expected.CacheName { + t.Fatalf("Expected %q but got %q for CacheName", v.Expected.CacheName, actual.CacheName) + } + + } +} + +func TestParseCacheIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CacheId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sToRaGeCaChE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/caches", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sToRaGeCaChE/cAcHeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/caches/cacheValue", + Expected: &CacheId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CacheName: "cacheValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/caches/cacheValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sToRaGeCaChE/cAcHeS/cAcHeVaLuE", + Expected: &CacheId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CacheName: "cAcHeVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sToRaGeCaChE/cAcHeS/cAcHeVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCacheIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", 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.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CacheName != v.Expected.CacheName { + t.Fatalf("Expected %q but got %q for CacheName", v.Expected.CacheName, actual.CacheName) + } + + } +} + +func TestSegmentsForCacheId(t *testing.T) { + segments := CacheId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CacheId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/storagecache/2024-03-01/caches/method_createorupdate.go b/resource-manager/storagecache/2024-03-01/caches/method_createorupdate.go new file mode 100644 index 00000000000..57311fefd47 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/method_createorupdate.go @@ -0,0 +1,76 @@ +package caches + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// 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 { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Cache +} + +// CreateOrUpdate ... +func (c CachesClient) CreateOrUpdate(ctx context.Context, id CacheId, input Cache) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c CachesClient) CreateOrUpdateThenPoll(ctx context.Context, id CacheId, input Cache) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/storagecache/2024-03-01/caches/method_debuginfo.go b/resource-manager/storagecache/2024-03-01/caches/method_debuginfo.go new file mode 100644 index 00000000000..2f7d7d7e5d3 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/method_debuginfo.go @@ -0,0 +1,71 @@ +package caches + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DebugInfoOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DebugInfo ... +func (c CachesClient) DebugInfo(ctx context.Context, id CacheId) (result DebugInfoOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/debugInfo", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DebugInfoThenPoll performs DebugInfo then polls until it's completed +func (c CachesClient) DebugInfoThenPoll(ctx context.Context, id CacheId) error { + result, err := c.DebugInfo(ctx, id) + if err != nil { + return fmt.Errorf("performing DebugInfo: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DebugInfo: %+v", err) + } + + return nil +} diff --git a/resource-manager/storagecache/2024-03-01/caches/method_delete.go b/resource-manager/storagecache/2024-03-01/caches/method_delete.go new file mode 100644 index 00000000000..68c13fe9d3e --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/method_delete.go @@ -0,0 +1,71 @@ +package caches + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// 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 { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c CachesClient) Delete(ctx context.Context, id CacheId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c CachesClient) DeleteThenPoll(ctx context.Context, id CacheId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/storagecache/2024-03-01/caches/method_flush.go b/resource-manager/storagecache/2024-03-01/caches/method_flush.go new file mode 100644 index 00000000000..f48100c40b3 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/method_flush.go @@ -0,0 +1,71 @@ +package caches + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlushOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Flush ... +func (c CachesClient) Flush(ctx context.Context, id CacheId) (result FlushOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/flush", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// FlushThenPoll performs Flush then polls until it's completed +func (c CachesClient) FlushThenPoll(ctx context.Context, id CacheId) error { + result, err := c.Flush(ctx, id) + if err != nil { + return fmt.Errorf("performing Flush: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Flush: %+v", err) + } + + return nil +} diff --git a/resource-manager/storagecache/2024-03-01/caches/method_get.go b/resource-manager/storagecache/2024-03-01/caches/method_get.go new file mode 100644 index 00000000000..189a309780c --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/method_get.go @@ -0,0 +1,54 @@ +package caches + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// 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 + OData *odata.OData + Model *Cache +} + +// Get ... +func (c CachesClient) Get(ctx context.Context, id CacheId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Cache + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/storagecache/2024-03-01/caches/method_list.go b/resource-manager/storagecache/2024-03-01/caches/method_list.go new file mode 100644 index 00000000000..7debad577b9 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/method_list.go @@ -0,0 +1,92 @@ +package caches + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// 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 + OData *odata.OData + Model *[]Cache +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Cache +} + +// List ... +func (c CachesClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.StorageCache/caches", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Cache `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c CachesClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, CacheOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CachesClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate CacheOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Cache, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/storagecache/2024-03-01/caches/method_listbyresourcegroup.go b/resource-manager/storagecache/2024-03-01/caches/method_listbyresourcegroup.go new file mode 100644 index 00000000000..3d0368a4d8d --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/method_listbyresourcegroup.go @@ -0,0 +1,92 @@ +package caches + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Cache +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []Cache +} + +// ListByResourceGroup ... +func (c CachesClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.StorageCache/caches", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Cache `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c CachesClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, CacheOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CachesClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate CacheOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]Cache, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/storagecache/2024-03-01/caches/method_pauseprimingjob.go b/resource-manager/storagecache/2024-03-01/caches/method_pauseprimingjob.go new file mode 100644 index 00000000000..2143408e156 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/method_pauseprimingjob.go @@ -0,0 +1,74 @@ +package caches + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PausePrimingJobOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// PausePrimingJob ... +func (c CachesClient) PausePrimingJob(ctx context.Context, id CacheId, input PrimingJobIdParameter) (result PausePrimingJobOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/pausePrimingJob", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// PausePrimingJobThenPoll performs PausePrimingJob then polls until it's completed +func (c CachesClient) PausePrimingJobThenPoll(ctx context.Context, id CacheId, input PrimingJobIdParameter) error { + result, err := c.PausePrimingJob(ctx, id, input) + if err != nil { + return fmt.Errorf("performing PausePrimingJob: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after PausePrimingJob: %+v", err) + } + + return nil +} diff --git a/resource-manager/storagecache/2024-03-01/caches/method_resumeprimingjob.go b/resource-manager/storagecache/2024-03-01/caches/method_resumeprimingjob.go new file mode 100644 index 00000000000..cdf78c14813 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/method_resumeprimingjob.go @@ -0,0 +1,74 @@ +package caches + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResumePrimingJobOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ResumePrimingJob ... +func (c CachesClient) ResumePrimingJob(ctx context.Context, id CacheId, input PrimingJobIdParameter) (result ResumePrimingJobOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resumePrimingJob", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ResumePrimingJobThenPoll performs ResumePrimingJob then polls until it's completed +func (c CachesClient) ResumePrimingJobThenPoll(ctx context.Context, id CacheId, input PrimingJobIdParameter) error { + result, err := c.ResumePrimingJob(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ResumePrimingJob: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ResumePrimingJob: %+v", err) + } + + return nil +} diff --git a/resource-manager/storagecache/2024-03-01/caches/method_spaceallocation.go b/resource-manager/storagecache/2024-03-01/caches/method_spaceallocation.go new file mode 100644 index 00000000000..0c40b20a7ea --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/method_spaceallocation.go @@ -0,0 +1,73 @@ +package caches + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SpaceAllocationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// SpaceAllocation ... +func (c CachesClient) SpaceAllocation(ctx context.Context, id CacheId, input []StorageTargetSpaceAllocation) (result SpaceAllocationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/spaceAllocation", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// SpaceAllocationThenPoll performs SpaceAllocation then polls until it's completed +func (c CachesClient) SpaceAllocationThenPoll(ctx context.Context, id CacheId, input []StorageTargetSpaceAllocation) error { + result, err := c.SpaceAllocation(ctx, id, input) + if err != nil { + return fmt.Errorf("performing SpaceAllocation: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SpaceAllocation: %+v", err) + } + + return nil +} diff --git a/resource-manager/storagecache/2024-03-01/caches/method_start.go b/resource-manager/storagecache/2024-03-01/caches/method_start.go new file mode 100644 index 00000000000..27b018179c2 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/method_start.go @@ -0,0 +1,71 @@ +package caches + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Start ... +func (c CachesClient) Start(ctx context.Context, id CacheId) (result StartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/start", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// StartThenPoll performs Start then polls until it's completed +func (c CachesClient) StartThenPoll(ctx context.Context, id CacheId) error { + result, err := c.Start(ctx, id) + if err != nil { + return fmt.Errorf("performing Start: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Start: %+v", err) + } + + return nil +} diff --git a/resource-manager/storagecache/2024-03-01/caches/method_startprimingjob.go b/resource-manager/storagecache/2024-03-01/caches/method_startprimingjob.go new file mode 100644 index 00000000000..79c3ebe5003 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/method_startprimingjob.go @@ -0,0 +1,73 @@ +package caches + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StartPrimingJobOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// StartPrimingJob ... +func (c CachesClient) StartPrimingJob(ctx context.Context, id CacheId, input PrimingJob) (result StartPrimingJobOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/startPrimingJob", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// StartPrimingJobThenPoll performs StartPrimingJob then polls until it's completed +func (c CachesClient) StartPrimingJobThenPoll(ctx context.Context, id CacheId, input PrimingJob) error { + result, err := c.StartPrimingJob(ctx, id, input) + if err != nil { + return fmt.Errorf("performing StartPrimingJob: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after StartPrimingJob: %+v", err) + } + + return nil +} diff --git a/resource-manager/storagecache/2024-03-01/caches/method_stop.go b/resource-manager/storagecache/2024-03-01/caches/method_stop.go new file mode 100644 index 00000000000..deb00ecf879 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/method_stop.go @@ -0,0 +1,71 @@ +package caches + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StopOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Stop ... +func (c CachesClient) Stop(ctx context.Context, id CacheId) (result StopOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/stop", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// StopThenPoll performs Stop then polls until it's completed +func (c CachesClient) StopThenPoll(ctx context.Context, id CacheId) error { + result, err := c.Stop(ctx, id) + if err != nil { + return fmt.Errorf("performing Stop: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Stop: %+v", err) + } + + return nil +} diff --git a/resource-manager/storagecache/2024-03-01/caches/method_stopprimingjob.go b/resource-manager/storagecache/2024-03-01/caches/method_stopprimingjob.go new file mode 100644 index 00000000000..59f381692d8 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/method_stopprimingjob.go @@ -0,0 +1,74 @@ +package caches + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StopPrimingJobOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// StopPrimingJob ... +func (c CachesClient) StopPrimingJob(ctx context.Context, id CacheId, input PrimingJobIdParameter) (result StopPrimingJobOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/stopPrimingJob", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// StopPrimingJobThenPoll performs StopPrimingJob then polls until it's completed +func (c CachesClient) StopPrimingJobThenPoll(ctx context.Context, id CacheId, input PrimingJobIdParameter) error { + result, err := c.StopPrimingJob(ctx, id, input) + if err != nil { + return fmt.Errorf("performing StopPrimingJob: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after StopPrimingJob: %+v", err) + } + + return nil +} diff --git a/resource-manager/storagecache/2024-03-01/caches/method_update.go b/resource-manager/storagecache/2024-03-01/caches/method_update.go new file mode 100644 index 00000000000..e58923ef8db --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/method_update.go @@ -0,0 +1,75 @@ +package caches + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Cache +} + +// Update ... +func (c CachesClient) Update(ctx context.Context, id CacheId, input Cache) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c CachesClient) UpdateThenPoll(ctx context.Context, id CacheId, input Cache) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/storagecache/2024-03-01/caches/method_upgradefirmware.go b/resource-manager/storagecache/2024-03-01/caches/method_upgradefirmware.go new file mode 100644 index 00000000000..1cf4338b22f --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/method_upgradefirmware.go @@ -0,0 +1,71 @@ +package caches + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpgradeFirmwareOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// UpgradeFirmware ... +func (c CachesClient) UpgradeFirmware(ctx context.Context, id CacheId) (result UpgradeFirmwareOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/upgrade", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpgradeFirmwareThenPoll performs UpgradeFirmware then polls until it's completed +func (c CachesClient) UpgradeFirmwareThenPoll(ctx context.Context, id CacheId) error { + result, err := c.UpgradeFirmware(ctx, id) + if err != nil { + return fmt.Errorf("performing UpgradeFirmware: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after UpgradeFirmware: %+v", err) + } + + return nil +} diff --git a/resource-manager/storagecache/2024-03-01/caches/model_cache.go b/resource-manager/storagecache/2024-03-01/caches/model_cache.go new file mode 100644 index 00000000000..ec5f8301324 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/model_cache.go @@ -0,0 +1,21 @@ +package caches + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "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 Cache struct { + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *CacheProperties `json:"properties,omitempty"` + Sku *CacheSku `json:"sku,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/caches/model_cacheactivedirectorysettings.go b/resource-manager/storagecache/2024-03-01/caches/model_cacheactivedirectorysettings.go new file mode 100644 index 00000000000..b3f3fa18db0 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/model_cacheactivedirectorysettings.go @@ -0,0 +1,14 @@ +package caches + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CacheActiveDirectorySettings struct { + CacheNetBiosName string `json:"cacheNetBiosName"` + Credentials *CacheActiveDirectorySettingsCredentials `json:"credentials,omitempty"` + DomainJoined *DomainJoinedType `json:"domainJoined,omitempty"` + DomainName string `json:"domainName"` + DomainNetBiosName string `json:"domainNetBiosName"` + PrimaryDnsIPAddress string `json:"primaryDnsIpAddress"` + SecondaryDnsIPAddress *string `json:"secondaryDnsIpAddress,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/caches/model_cacheactivedirectorysettingscredentials.go b/resource-manager/storagecache/2024-03-01/caches/model_cacheactivedirectorysettingscredentials.go new file mode 100644 index 00000000000..6b84584d601 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/model_cacheactivedirectorysettingscredentials.go @@ -0,0 +1,9 @@ +package caches + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CacheActiveDirectorySettingsCredentials struct { + Password *string `json:"password,omitempty"` + Username string `json:"username"` +} diff --git a/resource-manager/storagecache/2024-03-01/caches/model_cachedirectorysettings.go b/resource-manager/storagecache/2024-03-01/caches/model_cachedirectorysettings.go new file mode 100644 index 00000000000..f5475321210 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/model_cachedirectorysettings.go @@ -0,0 +1,9 @@ +package caches + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CacheDirectorySettings struct { + ActiveDirectory *CacheActiveDirectorySettings `json:"activeDirectory,omitempty"` + UsernameDownload *CacheUsernameDownloadSettings `json:"usernameDownload,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/caches/model_cacheencryptionsettings.go b/resource-manager/storagecache/2024-03-01/caches/model_cacheencryptionsettings.go new file mode 100644 index 00000000000..764929ae6ea --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/model_cacheencryptionsettings.go @@ -0,0 +1,9 @@ +package caches + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CacheEncryptionSettings struct { + KeyEncryptionKey *KeyVaultKeyReference `json:"keyEncryptionKey,omitempty"` + RotationToLatestKeyVersionEnabled *bool `json:"rotationToLatestKeyVersionEnabled,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/caches/model_cachehealth.go b/resource-manager/storagecache/2024-03-01/caches/model_cachehealth.go new file mode 100644 index 00000000000..d3b11bd1251 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/model_cachehealth.go @@ -0,0 +1,10 @@ +package caches + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CacheHealth struct { + Conditions *[]Condition `json:"conditions,omitempty"` + State *HealthStateType `json:"state,omitempty"` + StatusDescription *string `json:"statusDescription,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/caches/model_cachenetworksettings.go b/resource-manager/storagecache/2024-03-01/caches/model_cachenetworksettings.go new file mode 100644 index 00000000000..b7c9e73a6a6 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/model_cachenetworksettings.go @@ -0,0 +1,12 @@ +package caches + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CacheNetworkSettings struct { + DnsSearchDomain *string `json:"dnsSearchDomain,omitempty"` + DnsServers *[]string `json:"dnsServers,omitempty"` + Mtu *int64 `json:"mtu,omitempty"` + NtpServer *string `json:"ntpServer,omitempty"` + UtilityAddresses *[]string `json:"utilityAddresses,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/caches/model_cacheproperties.go b/resource-manager/storagecache/2024-03-01/caches/model_cacheproperties.go new file mode 100644 index 00000000000..80c654fbe57 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/model_cacheproperties.go @@ -0,0 +1,25 @@ +package caches + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CacheProperties struct { + CacheSizeGB *int64 `json:"cacheSizeGB,omitempty"` + DirectoryServicesSettings *CacheDirectorySettings `json:"directoryServicesSettings,omitempty"` + EncryptionSettings *CacheEncryptionSettings `json:"encryptionSettings,omitempty"` + Health *CacheHealth `json:"health,omitempty"` + MountAddresses *[]string `json:"mountAddresses,omitempty"` + NetworkSettings *CacheNetworkSettings `json:"networkSettings,omitempty"` + PrimingJobs *[]PrimingJob `json:"primingJobs,omitempty"` + ProvisioningState *ProvisioningStateType `json:"provisioningState,omitempty"` + SecuritySettings *CacheSecuritySettings `json:"securitySettings,omitempty"` + SpaceAllocation *[]StorageTargetSpaceAllocation `json:"spaceAllocation,omitempty"` + Subnet *string `json:"subnet,omitempty"` + UpgradeSettings *CacheUpgradeSettings `json:"upgradeSettings,omitempty"` + UpgradeStatus *CacheUpgradeStatus `json:"upgradeStatus,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/caches/model_cachesecuritysettings.go b/resource-manager/storagecache/2024-03-01/caches/model_cachesecuritysettings.go new file mode 100644 index 00000000000..bd288b1293a --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/model_cachesecuritysettings.go @@ -0,0 +1,8 @@ +package caches + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CacheSecuritySettings struct { + AccessPolicies *[]NfsAccessPolicy `json:"accessPolicies,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/caches/model_cachesku.go b/resource-manager/storagecache/2024-03-01/caches/model_cachesku.go new file mode 100644 index 00000000000..2e1c71cdc5f --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/model_cachesku.go @@ -0,0 +1,8 @@ +package caches + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CacheSku struct { + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/caches/model_cacheupgradesettings.go b/resource-manager/storagecache/2024-03-01/caches/model_cacheupgradesettings.go new file mode 100644 index 00000000000..87eb629f630 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/model_cacheupgradesettings.go @@ -0,0 +1,27 @@ +package caches + +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 CacheUpgradeSettings struct { + ScheduledTime *string `json:"scheduledTime,omitempty"` + UpgradeScheduleEnabled *bool `json:"upgradeScheduleEnabled,omitempty"` +} + +func (o *CacheUpgradeSettings) GetScheduledTimeAsTime() (*time.Time, error) { + if o.ScheduledTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ScheduledTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *CacheUpgradeSettings) SetScheduledTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ScheduledTime = &formatted +} diff --git a/resource-manager/storagecache/2024-03-01/caches/model_cacheupgradestatus.go b/resource-manager/storagecache/2024-03-01/caches/model_cacheupgradestatus.go new file mode 100644 index 00000000000..bcf2d5e2f42 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/model_cacheupgradestatus.go @@ -0,0 +1,42 @@ +package caches + +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 CacheUpgradeStatus struct { + CurrentFirmwareVersion *string `json:"currentFirmwareVersion,omitempty"` + FirmwareUpdateDeadline *string `json:"firmwareUpdateDeadline,omitempty"` + FirmwareUpdateStatus *FirmwareStatusType `json:"firmwareUpdateStatus,omitempty"` + LastFirmwareUpdate *string `json:"lastFirmwareUpdate,omitempty"` + PendingFirmwareVersion *string `json:"pendingFirmwareVersion,omitempty"` +} + +func (o *CacheUpgradeStatus) GetFirmwareUpdateDeadlineAsTime() (*time.Time, error) { + if o.FirmwareUpdateDeadline == nil { + return nil, nil + } + return dates.ParseAsFormat(o.FirmwareUpdateDeadline, "2006-01-02T15:04:05Z07:00") +} + +func (o *CacheUpgradeStatus) SetFirmwareUpdateDeadlineAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.FirmwareUpdateDeadline = &formatted +} + +func (o *CacheUpgradeStatus) GetLastFirmwareUpdateAsTime() (*time.Time, error) { + if o.LastFirmwareUpdate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastFirmwareUpdate, "2006-01-02T15:04:05Z07:00") +} + +func (o *CacheUpgradeStatus) SetLastFirmwareUpdateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastFirmwareUpdate = &formatted +} diff --git a/resource-manager/storagecache/2024-03-01/caches/model_cacheusernamedownloadsettings.go b/resource-manager/storagecache/2024-03-01/caches/model_cacheusernamedownloadsettings.go new file mode 100644 index 00000000000..3bf85af6380 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/model_cacheusernamedownloadsettings.go @@ -0,0 +1,19 @@ +package caches + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CacheUsernameDownloadSettings struct { + AutoDownloadCertificate *bool `json:"autoDownloadCertificate,omitempty"` + CaCertificateURI *string `json:"caCertificateURI,omitempty"` + Credentials *CacheUsernameDownloadSettingsCredentials `json:"credentials,omitempty"` + EncryptLdapConnection *bool `json:"encryptLdapConnection,omitempty"` + ExtendedGroups *bool `json:"extendedGroups,omitempty"` + GroupFileURI *string `json:"groupFileURI,omitempty"` + LdapBaseDN *string `json:"ldapBaseDN,omitempty"` + LdapServer *string `json:"ldapServer,omitempty"` + RequireValidCertificate *bool `json:"requireValidCertificate,omitempty"` + UserFileURI *string `json:"userFileURI,omitempty"` + UsernameDownloaded *UsernameDownloadedType `json:"usernameDownloaded,omitempty"` + UsernameSource *UsernameSource `json:"usernameSource,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/caches/model_cacheusernamedownloadsettingscredentials.go b/resource-manager/storagecache/2024-03-01/caches/model_cacheusernamedownloadsettingscredentials.go new file mode 100644 index 00000000000..d3cd2f73e58 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/model_cacheusernamedownloadsettingscredentials.go @@ -0,0 +1,9 @@ +package caches + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CacheUsernameDownloadSettingsCredentials struct { + BindDn *string `json:"bindDn,omitempty"` + BindPassword *string `json:"bindPassword,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/caches/model_condition.go b/resource-manager/storagecache/2024-03-01/caches/model_condition.go new file mode 100644 index 00000000000..1f8853b97b8 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/model_condition.go @@ -0,0 +1,27 @@ +package caches + +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 Condition struct { + Message *string `json:"message,omitempty"` + Timestamp *string `json:"timestamp,omitempty"` +} + +func (o *Condition) GetTimestampAsTime() (*time.Time, error) { + if o.Timestamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.Timestamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *Condition) SetTimestampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Timestamp = &formatted +} diff --git a/resource-manager/storagecache/2024-03-01/caches/model_keyvaultkeyreference.go b/resource-manager/storagecache/2024-03-01/caches/model_keyvaultkeyreference.go new file mode 100644 index 00000000000..b5e432d0e6f --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/model_keyvaultkeyreference.go @@ -0,0 +1,9 @@ +package caches + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyVaultKeyReference struct { + KeyUrl string `json:"keyUrl"` + SourceVault KeyVaultKeyReferenceSourceVault `json:"sourceVault"` +} diff --git a/resource-manager/storagecache/2024-03-01/caches/model_keyvaultkeyreferencesourcevault.go b/resource-manager/storagecache/2024-03-01/caches/model_keyvaultkeyreferencesourcevault.go new file mode 100644 index 00000000000..b40bced4f85 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/model_keyvaultkeyreferencesourcevault.go @@ -0,0 +1,8 @@ +package caches + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyVaultKeyReferenceSourceVault struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/caches/model_nfsaccesspolicy.go b/resource-manager/storagecache/2024-03-01/caches/model_nfsaccesspolicy.go new file mode 100644 index 00000000000..0c7abc41b76 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/model_nfsaccesspolicy.go @@ -0,0 +1,9 @@ +package caches + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NfsAccessPolicy struct { + AccessRules []NfsAccessRule `json:"accessRules"` + Name string `json:"name"` +} diff --git a/resource-manager/storagecache/2024-03-01/caches/model_nfsaccessrule.go b/resource-manager/storagecache/2024-03-01/caches/model_nfsaccessrule.go new file mode 100644 index 00000000000..55683cce978 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/model_nfsaccessrule.go @@ -0,0 +1,15 @@ +package caches + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NfsAccessRule struct { + Access NfsAccessRuleAccess `json:"access"` + AnonymousGID *string `json:"anonymousGID,omitempty"` + AnonymousUID *string `json:"anonymousUID,omitempty"` + Filter *string `json:"filter,omitempty"` + RootSquash *bool `json:"rootSquash,omitempty"` + Scope NfsAccessRuleScope `json:"scope"` + SubmountAccess *bool `json:"submountAccess,omitempty"` + Suid *bool `json:"suid,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/caches/model_primingjob.go b/resource-manager/storagecache/2024-03-01/caches/model_primingjob.go new file mode 100644 index 00000000000..7050afae80c --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/model_primingjob.go @@ -0,0 +1,14 @@ +package caches + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrimingJob struct { + PrimingJobDetails *string `json:"primingJobDetails,omitempty"` + PrimingJobId *string `json:"primingJobId,omitempty"` + PrimingJobName string `json:"primingJobName"` + PrimingJobPercentComplete *float64 `json:"primingJobPercentComplete,omitempty"` + PrimingJobState *PrimingJobState `json:"primingJobState,omitempty"` + PrimingJobStatus *string `json:"primingJobStatus,omitempty"` + PrimingManifestUrl string `json:"primingManifestUrl"` +} diff --git a/resource-manager/storagecache/2024-03-01/caches/model_primingjobidparameter.go b/resource-manager/storagecache/2024-03-01/caches/model_primingjobidparameter.go new file mode 100644 index 00000000000..bcdefcadf6a --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/model_primingjobidparameter.go @@ -0,0 +1,8 @@ +package caches + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrimingJobIdParameter struct { + PrimingJobId string `json:"primingJobId"` +} diff --git a/resource-manager/storagecache/2024-03-01/caches/model_storagetargetspaceallocation.go b/resource-manager/storagecache/2024-03-01/caches/model_storagetargetspaceallocation.go new file mode 100644 index 00000000000..d0787a3a423 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/model_storagetargetspaceallocation.go @@ -0,0 +1,9 @@ +package caches + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageTargetSpaceAllocation struct { + AllocationPercentage *int64 `json:"allocationPercentage,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/caches/predicates.go b/resource-manager/storagecache/2024-03-01/caches/predicates.go new file mode 100644 index 00000000000..67fc4aa4f86 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/predicates.go @@ -0,0 +1,32 @@ +package caches + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CacheOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p CacheOperationPredicate) Matches(input Cache) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + 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/resource-manager/storagecache/2024-03-01/caches/version.go b/resource-manager/storagecache/2024-03-01/caches/version.go new file mode 100644 index 00000000000..89c8ed97b46 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/caches/version.go @@ -0,0 +1,12 @@ +package caches + +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 = "2024-03-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/caches/%s", defaultApiVersion) +} diff --git a/resource-manager/storagecache/2024-03-01/client.go b/resource-manager/storagecache/2024-03-01/client.go new file mode 100644 index 00000000000..69d3c59d640 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/client.go @@ -0,0 +1,82 @@ +package v2024_03_01 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/resource-manager/storagecache/2024-03-01/amlfilesystems" + "github.com/hashicorp/go-azure-sdk/resource-manager/storagecache/2024-03-01/ascusages" + "github.com/hashicorp/go-azure-sdk/resource-manager/storagecache/2024-03-01/caches" + "github.com/hashicorp/go-azure-sdk/resource-manager/storagecache/2024-03-01/importjobs" + "github.com/hashicorp/go-azure-sdk/resource-manager/storagecache/2024-03-01/skus" + "github.com/hashicorp/go-azure-sdk/resource-manager/storagecache/2024-03-01/storagetargets" + "github.com/hashicorp/go-azure-sdk/resource-manager/storagecache/2024-03-01/usagemodels" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + AmlFilesystems *amlfilesystems.AmlFilesystemsClient + AscUsages *ascusages.AscUsagesClient + Caches *caches.CachesClient + ImportJobs *importjobs.ImportJobsClient + SKUs *skus.SKUsClient + StorageTargets *storagetargets.StorageTargetsClient + UsageModels *usagemodels.UsageModelsClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + amlFilesystemsClient, err := amlfilesystems.NewAmlFilesystemsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AmlFilesystems client: %+v", err) + } + configureFunc(amlFilesystemsClient.Client) + + ascUsagesClient, err := ascusages.NewAscUsagesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AscUsages client: %+v", err) + } + configureFunc(ascUsagesClient.Client) + + cachesClient, err := caches.NewCachesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Caches client: %+v", err) + } + configureFunc(cachesClient.Client) + + importJobsClient, err := importjobs.NewImportJobsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ImportJobs client: %+v", err) + } + configureFunc(importJobsClient.Client) + + sKUsClient, err := skus.NewSKUsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SKUs client: %+v", err) + } + configureFunc(sKUsClient.Client) + + storageTargetsClient, err := storagetargets.NewStorageTargetsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building StorageTargets client: %+v", err) + } + configureFunc(storageTargetsClient.Client) + + usageModelsClient, err := usagemodels.NewUsageModelsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building UsageModels client: %+v", err) + } + configureFunc(usageModelsClient.Client) + + return &Client{ + AmlFilesystems: amlFilesystemsClient, + AscUsages: ascUsagesClient, + Caches: cachesClient, + ImportJobs: importJobsClient, + SKUs: sKUsClient, + StorageTargets: storageTargetsClient, + UsageModels: usageModelsClient, + }, nil +} diff --git a/resource-manager/storagecache/2024-03-01/importjobs/README.md b/resource-manager/storagecache/2024-03-01/importjobs/README.md new file mode 100644 index 00000000000..1e6198a71d2 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/importjobs/README.md @@ -0,0 +1,99 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/storagecache/2024-03-01/importjobs` Documentation + +The `importjobs` SDK allows for interaction with the Azure Resource Manager Service `storagecache` (API Version `2024-03-01`). + +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/storagecache/2024-03-01/importjobs" +``` + + +### Client Initialization + +```go +client := importjobs.NewImportJobsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ImportJobsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := importjobs.NewImportJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "amlFilesystemValue", "importJobValue") + +payload := importjobs.ImportJob{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ImportJobsClient.Delete` + +```go +ctx := context.TODO() +id := importjobs.NewImportJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "amlFilesystemValue", "importJobValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ImportJobsClient.Get` + +```go +ctx := context.TODO() +id := importjobs.NewImportJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "amlFilesystemValue", "importJobValue") + +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: `ImportJobsClient.ListByAmlFilesystem` + +```go +ctx := context.TODO() +id := importjobs.NewAmlFilesystemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "amlFilesystemValue") + +// alternatively `client.ListByAmlFilesystem(ctx, id)` can be used to do batched pagination +items, err := client.ListByAmlFilesystemComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ImportJobsClient.Update` + +```go +ctx := context.TODO() +id := importjobs.NewImportJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "amlFilesystemValue", "importJobValue") + +payload := importjobs.ImportJobUpdate{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/storagecache/2024-03-01/importjobs/client.go b/resource-manager/storagecache/2024-03-01/importjobs/client.go new file mode 100644 index 00000000000..9cb987076a1 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/importjobs/client.go @@ -0,0 +1,26 @@ +package importjobs + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ImportJobsClient struct { + Client *resourcemanager.Client +} + +func NewImportJobsClientWithBaseURI(sdkApi sdkEnv.Api) (*ImportJobsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "importjobs", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ImportJobsClient: %+v", err) + } + + return &ImportJobsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/storagecache/2024-03-01/importjobs/constants.go b/resource-manager/storagecache/2024-03-01/importjobs/constants.go new file mode 100644 index 00000000000..33ac0adbd3f --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/importjobs/constants.go @@ -0,0 +1,163 @@ +package importjobs + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConflictResolutionMode string + +const ( + ConflictResolutionModeFail ConflictResolutionMode = "Fail" + ConflictResolutionModeOverwriteAlways ConflictResolutionMode = "OverwriteAlways" + ConflictResolutionModeOverwriteIfDirty ConflictResolutionMode = "OverwriteIfDirty" + ConflictResolutionModeSkip ConflictResolutionMode = "Skip" +) + +func PossibleValuesForConflictResolutionMode() []string { + return []string{ + string(ConflictResolutionModeFail), + string(ConflictResolutionModeOverwriteAlways), + string(ConflictResolutionModeOverwriteIfDirty), + string(ConflictResolutionModeSkip), + } +} + +func (s *ConflictResolutionMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConflictResolutionMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConflictResolutionMode(input string) (*ConflictResolutionMode, error) { + vals := map[string]ConflictResolutionMode{ + "fail": ConflictResolutionModeFail, + "overwritealways": ConflictResolutionModeOverwriteAlways, + "overwriteifdirty": ConflictResolutionModeOverwriteIfDirty, + "skip": ConflictResolutionModeSkip, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConflictResolutionMode(input) + return &out, nil +} + +type ImportJobProvisioningStateType string + +const ( + ImportJobProvisioningStateTypeCanceled ImportJobProvisioningStateType = "Canceled" + ImportJobProvisioningStateTypeCreating ImportJobProvisioningStateType = "Creating" + ImportJobProvisioningStateTypeDeleting ImportJobProvisioningStateType = "Deleting" + ImportJobProvisioningStateTypeFailed ImportJobProvisioningStateType = "Failed" + ImportJobProvisioningStateTypeSucceeded ImportJobProvisioningStateType = "Succeeded" + ImportJobProvisioningStateTypeUpdating ImportJobProvisioningStateType = "Updating" +) + +func PossibleValuesForImportJobProvisioningStateType() []string { + return []string{ + string(ImportJobProvisioningStateTypeCanceled), + string(ImportJobProvisioningStateTypeCreating), + string(ImportJobProvisioningStateTypeDeleting), + string(ImportJobProvisioningStateTypeFailed), + string(ImportJobProvisioningStateTypeSucceeded), + string(ImportJobProvisioningStateTypeUpdating), + } +} + +func (s *ImportJobProvisioningStateType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseImportJobProvisioningStateType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseImportJobProvisioningStateType(input string) (*ImportJobProvisioningStateType, error) { + vals := map[string]ImportJobProvisioningStateType{ + "canceled": ImportJobProvisioningStateTypeCanceled, + "creating": ImportJobProvisioningStateTypeCreating, + "deleting": ImportJobProvisioningStateTypeDeleting, + "failed": ImportJobProvisioningStateTypeFailed, + "succeeded": ImportJobProvisioningStateTypeSucceeded, + "updating": ImportJobProvisioningStateTypeUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ImportJobProvisioningStateType(input) + return &out, nil +} + +type ImportStatusType string + +const ( + ImportStatusTypeCanceled ImportStatusType = "Canceled" + ImportStatusTypeCancelling ImportStatusType = "Cancelling" + ImportStatusTypeCompleted ImportStatusType = "Completed" + ImportStatusTypeCompletedPartial ImportStatusType = "CompletedPartial" + ImportStatusTypeFailed ImportStatusType = "Failed" + ImportStatusTypeInProgress ImportStatusType = "InProgress" +) + +func PossibleValuesForImportStatusType() []string { + return []string{ + string(ImportStatusTypeCanceled), + string(ImportStatusTypeCancelling), + string(ImportStatusTypeCompleted), + string(ImportStatusTypeCompletedPartial), + string(ImportStatusTypeFailed), + string(ImportStatusTypeInProgress), + } +} + +func (s *ImportStatusType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseImportStatusType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseImportStatusType(input string) (*ImportStatusType, error) { + vals := map[string]ImportStatusType{ + "canceled": ImportStatusTypeCanceled, + "cancelling": ImportStatusTypeCancelling, + "completed": ImportStatusTypeCompleted, + "completedpartial": ImportStatusTypeCompletedPartial, + "failed": ImportStatusTypeFailed, + "inprogress": ImportStatusTypeInProgress, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ImportStatusType(input) + return &out, nil +} diff --git a/resource-manager/storagecache/2024-03-01/importjobs/id_amlfilesystem.go b/resource-manager/storagecache/2024-03-01/importjobs/id_amlfilesystem.go new file mode 100644 index 00000000000..6be9e672b8a --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/importjobs/id_amlfilesystem.go @@ -0,0 +1,130 @@ +package importjobs + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&AmlFilesystemId{}) +} + +var _ resourceids.ResourceId = &AmlFilesystemId{} + +// AmlFilesystemId is a struct representing the Resource ID for a Aml Filesystem +type AmlFilesystemId struct { + SubscriptionId string + ResourceGroupName string + AmlFilesystemName string +} + +// NewAmlFilesystemID returns a new AmlFilesystemId struct +func NewAmlFilesystemID(subscriptionId string, resourceGroupName string, amlFilesystemName string) AmlFilesystemId { + return AmlFilesystemId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + AmlFilesystemName: amlFilesystemName, + } +} + +// ParseAmlFilesystemID parses 'input' into a AmlFilesystemId +func ParseAmlFilesystemID(input string) (*AmlFilesystemId, error) { + parser := resourceids.NewParserFromResourceIdType(&AmlFilesystemId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AmlFilesystemId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAmlFilesystemIDInsensitively parses 'input' case-insensitively into a AmlFilesystemId +// note: this method should only be used for API response data and not user input +func ParseAmlFilesystemIDInsensitively(input string) (*AmlFilesystemId, error) { + parser := resourceids.NewParserFromResourceIdType(&AmlFilesystemId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AmlFilesystemId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AmlFilesystemId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.AmlFilesystemName, ok = input.Parsed["amlFilesystemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "amlFilesystemName", input) + } + + return nil +} + +// ValidateAmlFilesystemID checks that 'input' can be parsed as a Aml Filesystem ID +func ValidateAmlFilesystemID(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 := ParseAmlFilesystemID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Aml Filesystem ID +func (id AmlFilesystemId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.StorageCache/amlFilesystems/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.AmlFilesystemName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Aml Filesystem ID +func (id AmlFilesystemId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftStorageCache", "Microsoft.StorageCache", "Microsoft.StorageCache"), + resourceids.StaticSegment("staticAmlFilesystems", "amlFilesystems", "amlFilesystems"), + resourceids.UserSpecifiedSegment("amlFilesystemName", "amlFilesystemValue"), + } +} + +// String returns a human-readable description of this Aml Filesystem ID +func (id AmlFilesystemId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Aml Filesystem Name: %q", id.AmlFilesystemName), + } + return fmt.Sprintf("Aml Filesystem (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/storagecache/2024-03-01/importjobs/id_amlfilesystem_test.go b/resource-manager/storagecache/2024-03-01/importjobs/id_amlfilesystem_test.go new file mode 100644 index 00000000000..1968d7ac3b5 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/importjobs/id_amlfilesystem_test.go @@ -0,0 +1,282 @@ +package importjobs + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &AmlFilesystemId{} + +func TestNewAmlFilesystemID(t *testing.T) { + id := NewAmlFilesystemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "amlFilesystemValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.AmlFilesystemName != "amlFilesystemValue" { + t.Fatalf("Expected %q but got %q for Segment 'AmlFilesystemName'", id.AmlFilesystemName, "amlFilesystemValue") + } +} + +func TestFormatAmlFilesystemID(t *testing.T) { + actual := NewAmlFilesystemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "amlFilesystemValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/amlFilesystems/amlFilesystemValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAmlFilesystemID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AmlFilesystemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/amlFilesystems", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/amlFilesystems/amlFilesystemValue", + Expected: &AmlFilesystemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + AmlFilesystemName: "amlFilesystemValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/amlFilesystems/amlFilesystemValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAmlFilesystemID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", 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.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.AmlFilesystemName != v.Expected.AmlFilesystemName { + t.Fatalf("Expected %q but got %q for AmlFilesystemName", v.Expected.AmlFilesystemName, actual.AmlFilesystemName) + } + + } +} + +func TestParseAmlFilesystemIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AmlFilesystemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sToRaGeCaChE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/amlFilesystems", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sToRaGeCaChE/aMlFiLeSyStEmS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/amlFilesystems/amlFilesystemValue", + Expected: &AmlFilesystemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + AmlFilesystemName: "amlFilesystemValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/amlFilesystems/amlFilesystemValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sToRaGeCaChE/aMlFiLeSyStEmS/aMlFiLeSyStEmVaLuE", + Expected: &AmlFilesystemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + AmlFilesystemName: "aMlFiLeSyStEmVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sToRaGeCaChE/aMlFiLeSyStEmS/aMlFiLeSyStEmVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAmlFilesystemIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", 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.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.AmlFilesystemName != v.Expected.AmlFilesystemName { + t.Fatalf("Expected %q but got %q for AmlFilesystemName", v.Expected.AmlFilesystemName, actual.AmlFilesystemName) + } + + } +} + +func TestSegmentsForAmlFilesystemId(t *testing.T) { + segments := AmlFilesystemId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AmlFilesystemId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/storagecache/2024-03-01/importjobs/id_importjob.go b/resource-manager/storagecache/2024-03-01/importjobs/id_importjob.go new file mode 100644 index 00000000000..7f3d3576a73 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/importjobs/id_importjob.go @@ -0,0 +1,139 @@ +package importjobs + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ImportJobId{}) +} + +var _ resourceids.ResourceId = &ImportJobId{} + +// ImportJobId is a struct representing the Resource ID for a Import Job +type ImportJobId struct { + SubscriptionId string + ResourceGroupName string + AmlFilesystemName string + ImportJobName string +} + +// NewImportJobID returns a new ImportJobId struct +func NewImportJobID(subscriptionId string, resourceGroupName string, amlFilesystemName string, importJobName string) ImportJobId { + return ImportJobId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + AmlFilesystemName: amlFilesystemName, + ImportJobName: importJobName, + } +} + +// ParseImportJobID parses 'input' into a ImportJobId +func ParseImportJobID(input string) (*ImportJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&ImportJobId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ImportJobId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseImportJobIDInsensitively parses 'input' case-insensitively into a ImportJobId +// note: this method should only be used for API response data and not user input +func ParseImportJobIDInsensitively(input string) (*ImportJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&ImportJobId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ImportJobId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ImportJobId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.AmlFilesystemName, ok = input.Parsed["amlFilesystemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "amlFilesystemName", input) + } + + if id.ImportJobName, ok = input.Parsed["importJobName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "importJobName", input) + } + + return nil +} + +// ValidateImportJobID checks that 'input' can be parsed as a Import Job ID +func ValidateImportJobID(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 := ParseImportJobID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Import Job ID +func (id ImportJobId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.StorageCache/amlFilesystems/%s/importJobs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.AmlFilesystemName, id.ImportJobName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Import Job ID +func (id ImportJobId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftStorageCache", "Microsoft.StorageCache", "Microsoft.StorageCache"), + resourceids.StaticSegment("staticAmlFilesystems", "amlFilesystems", "amlFilesystems"), + resourceids.UserSpecifiedSegment("amlFilesystemName", "amlFilesystemValue"), + resourceids.StaticSegment("staticImportJobs", "importJobs", "importJobs"), + resourceids.UserSpecifiedSegment("importJobName", "importJobValue"), + } +} + +// String returns a human-readable description of this Import Job ID +func (id ImportJobId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Aml Filesystem Name: %q", id.AmlFilesystemName), + fmt.Sprintf("Import Job Name: %q", id.ImportJobName), + } + return fmt.Sprintf("Import Job (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/storagecache/2024-03-01/importjobs/id_importjob_test.go b/resource-manager/storagecache/2024-03-01/importjobs/id_importjob_test.go new file mode 100644 index 00000000000..d101d8f6d2a --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/importjobs/id_importjob_test.go @@ -0,0 +1,327 @@ +package importjobs + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ImportJobId{} + +func TestNewImportJobID(t *testing.T) { + id := NewImportJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "amlFilesystemValue", "importJobValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.AmlFilesystemName != "amlFilesystemValue" { + t.Fatalf("Expected %q but got %q for Segment 'AmlFilesystemName'", id.AmlFilesystemName, "amlFilesystemValue") + } + + if id.ImportJobName != "importJobValue" { + t.Fatalf("Expected %q but got %q for Segment 'ImportJobName'", id.ImportJobName, "importJobValue") + } +} + +func TestFormatImportJobID(t *testing.T) { + actual := NewImportJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "amlFilesystemValue", "importJobValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/amlFilesystems/amlFilesystemValue/importJobs/importJobValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseImportJobID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ImportJobId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/amlFilesystems", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/amlFilesystems/amlFilesystemValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/amlFilesystems/amlFilesystemValue/importJobs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/amlFilesystems/amlFilesystemValue/importJobs/importJobValue", + Expected: &ImportJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + AmlFilesystemName: "amlFilesystemValue", + ImportJobName: "importJobValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/amlFilesystems/amlFilesystemValue/importJobs/importJobValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseImportJobID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", 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.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.AmlFilesystemName != v.Expected.AmlFilesystemName { + t.Fatalf("Expected %q but got %q for AmlFilesystemName", v.Expected.AmlFilesystemName, actual.AmlFilesystemName) + } + + if actual.ImportJobName != v.Expected.ImportJobName { + t.Fatalf("Expected %q but got %q for ImportJobName", v.Expected.ImportJobName, actual.ImportJobName) + } + + } +} + +func TestParseImportJobIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ImportJobId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sToRaGeCaChE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/amlFilesystems", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sToRaGeCaChE/aMlFiLeSyStEmS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/amlFilesystems/amlFilesystemValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sToRaGeCaChE/aMlFiLeSyStEmS/aMlFiLeSyStEmVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/amlFilesystems/amlFilesystemValue/importJobs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sToRaGeCaChE/aMlFiLeSyStEmS/aMlFiLeSyStEmVaLuE/iMpOrTjObS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/amlFilesystems/amlFilesystemValue/importJobs/importJobValue", + Expected: &ImportJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + AmlFilesystemName: "amlFilesystemValue", + ImportJobName: "importJobValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/amlFilesystems/amlFilesystemValue/importJobs/importJobValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sToRaGeCaChE/aMlFiLeSyStEmS/aMlFiLeSyStEmVaLuE/iMpOrTjObS/iMpOrTjObVaLuE", + Expected: &ImportJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + AmlFilesystemName: "aMlFiLeSyStEmVaLuE", + ImportJobName: "iMpOrTjObVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sToRaGeCaChE/aMlFiLeSyStEmS/aMlFiLeSyStEmVaLuE/iMpOrTjObS/iMpOrTjObVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseImportJobIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", 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.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.AmlFilesystemName != v.Expected.AmlFilesystemName { + t.Fatalf("Expected %q but got %q for AmlFilesystemName", v.Expected.AmlFilesystemName, actual.AmlFilesystemName) + } + + if actual.ImportJobName != v.Expected.ImportJobName { + t.Fatalf("Expected %q but got %q for ImportJobName", v.Expected.ImportJobName, actual.ImportJobName) + } + + } +} + +func TestSegmentsForImportJobId(t *testing.T) { + segments := ImportJobId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ImportJobId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/storagecache/2024-03-01/importjobs/method_createorupdate.go b/resource-manager/storagecache/2024-03-01/importjobs/method_createorupdate.go new file mode 100644 index 00000000000..f6a7d6b90f6 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/importjobs/method_createorupdate.go @@ -0,0 +1,75 @@ +package importjobs + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// 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 { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ImportJob +} + +// CreateOrUpdate ... +func (c ImportJobsClient) CreateOrUpdate(ctx context.Context, id ImportJobId, input ImportJob) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ImportJobsClient) CreateOrUpdateThenPoll(ctx context.Context, id ImportJobId, input ImportJob) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/storagecache/2024-03-01/importjobs/method_delete.go b/resource-manager/storagecache/2024-03-01/importjobs/method_delete.go new file mode 100644 index 00000000000..c15bffe7a13 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/importjobs/method_delete.go @@ -0,0 +1,70 @@ +package importjobs + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// 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 { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ImportJobsClient) Delete(ctx context.Context, id ImportJobId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ImportJobsClient) DeleteThenPoll(ctx context.Context, id ImportJobId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/storagecache/2024-03-01/importjobs/method_get.go b/resource-manager/storagecache/2024-03-01/importjobs/method_get.go new file mode 100644 index 00000000000..e6a200b98cf --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/importjobs/method_get.go @@ -0,0 +1,54 @@ +package importjobs + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// 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 + OData *odata.OData + Model *ImportJob +} + +// Get ... +func (c ImportJobsClient) Get(ctx context.Context, id ImportJobId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ImportJob + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/storagecache/2024-03-01/importjobs/method_listbyamlfilesystem.go b/resource-manager/storagecache/2024-03-01/importjobs/method_listbyamlfilesystem.go new file mode 100644 index 00000000000..ca2c97ea47b --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/importjobs/method_listbyamlfilesystem.go @@ -0,0 +1,91 @@ +package importjobs + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByAmlFilesystemOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ImportJob +} + +type ListByAmlFilesystemCompleteResult struct { + LatestHttpResponse *http.Response + Items []ImportJob +} + +// ListByAmlFilesystem ... +func (c ImportJobsClient) ListByAmlFilesystem(ctx context.Context, id AmlFilesystemId) (result ListByAmlFilesystemOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/importJobs", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ImportJob `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByAmlFilesystemComplete retrieves all the results into a single object +func (c ImportJobsClient) ListByAmlFilesystemComplete(ctx context.Context, id AmlFilesystemId) (ListByAmlFilesystemCompleteResult, error) { + return c.ListByAmlFilesystemCompleteMatchingPredicate(ctx, id, ImportJobOperationPredicate{}) +} + +// ListByAmlFilesystemCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ImportJobsClient) ListByAmlFilesystemCompleteMatchingPredicate(ctx context.Context, id AmlFilesystemId, predicate ImportJobOperationPredicate) (result ListByAmlFilesystemCompleteResult, err error) { + items := make([]ImportJob, 0) + + resp, err := c.ListByAmlFilesystem(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByAmlFilesystemCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/storagecache/2024-03-01/importjobs/method_update.go b/resource-manager/storagecache/2024-03-01/importjobs/method_update.go new file mode 100644 index 00000000000..475813f834e --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/importjobs/method_update.go @@ -0,0 +1,75 @@ +package importjobs + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ImportJob +} + +// Update ... +func (c ImportJobsClient) Update(ctx context.Context, id ImportJobId, input ImportJobUpdate) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c ImportJobsClient) UpdateThenPoll(ctx context.Context, id ImportJobId, input ImportJobUpdate) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/storagecache/2024-03-01/importjobs/model_importjob.go b/resource-manager/storagecache/2024-03-01/importjobs/model_importjob.go new file mode 100644 index 00000000000..2c589ffc3bb --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/importjobs/model_importjob.go @@ -0,0 +1,18 @@ +package importjobs + +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 ImportJob struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *ImportJobProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/importjobs/model_importjobproperties.go b/resource-manager/storagecache/2024-03-01/importjobs/model_importjobproperties.go new file mode 100644 index 00000000000..da10b7c481f --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/importjobs/model_importjobproperties.go @@ -0,0 +1,12 @@ +package importjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ImportJobProperties struct { + ConflictResolutionMode *ConflictResolutionMode `json:"conflictResolutionMode,omitempty"` + ImportPrefixes *[]string `json:"importPrefixes,omitempty"` + MaximumErrors *int64 `json:"maximumErrors,omitempty"` + ProvisioningState *ImportJobProvisioningStateType `json:"provisioningState,omitempty"` + Status *ImportJobPropertiesStatus `json:"status,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/importjobs/model_importjobpropertiesstatus.go b/resource-manager/storagecache/2024-03-01/importjobs/model_importjobpropertiesstatus.go new file mode 100644 index 00000000000..b164ca7c377 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/importjobs/model_importjobpropertiesstatus.go @@ -0,0 +1,47 @@ +package importjobs + +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 ImportJobPropertiesStatus struct { + BlobsImportedPerSecond *int64 `json:"blobsImportedPerSecond,omitempty"` + BlobsWalkedPerSecond *int64 `json:"blobsWalkedPerSecond,omitempty"` + LastCompletionTime *string `json:"lastCompletionTime,omitempty"` + LastStartedTime *string `json:"lastStartedTime,omitempty"` + State *ImportStatusType `json:"state,omitempty"` + StatusMessage *string `json:"statusMessage,omitempty"` + TotalBlobsImported *int64 `json:"totalBlobsImported,omitempty"` + TotalBlobsWalked *int64 `json:"totalBlobsWalked,omitempty"` + TotalConflicts *int64 `json:"totalConflicts,omitempty"` + TotalErrors *int64 `json:"totalErrors,omitempty"` +} + +func (o *ImportJobPropertiesStatus) GetLastCompletionTimeAsTime() (*time.Time, error) { + if o.LastCompletionTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastCompletionTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ImportJobPropertiesStatus) SetLastCompletionTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastCompletionTime = &formatted +} + +func (o *ImportJobPropertiesStatus) GetLastStartedTimeAsTime() (*time.Time, error) { + if o.LastStartedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastStartedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ImportJobPropertiesStatus) SetLastStartedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastStartedTime = &formatted +} diff --git a/resource-manager/storagecache/2024-03-01/importjobs/model_importjobupdate.go b/resource-manager/storagecache/2024-03-01/importjobs/model_importjobupdate.go new file mode 100644 index 00000000000..01b9a6d0a80 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/importjobs/model_importjobupdate.go @@ -0,0 +1,8 @@ +package importjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ImportJobUpdate struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/importjobs/predicates.go b/resource-manager/storagecache/2024-03-01/importjobs/predicates.go new file mode 100644 index 00000000000..f3d555c3c45 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/importjobs/predicates.go @@ -0,0 +1,32 @@ +package importjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ImportJobOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ImportJobOperationPredicate) Matches(input ImportJob) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + 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/resource-manager/storagecache/2024-03-01/importjobs/version.go b/resource-manager/storagecache/2024-03-01/importjobs/version.go new file mode 100644 index 00000000000..c8e4e5eb790 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/importjobs/version.go @@ -0,0 +1,12 @@ +package importjobs + +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 = "2024-03-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/importjobs/%s", defaultApiVersion) +} diff --git a/resource-manager/storagecache/2024-03-01/skus/README.md b/resource-manager/storagecache/2024-03-01/skus/README.md new file mode 100644 index 00000000000..9dcc6dad053 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/skus/README.md @@ -0,0 +1,38 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/storagecache/2024-03-01/skus` Documentation + +The `skus` SDK allows for interaction with the Azure Resource Manager Service `storagecache` (API Version `2024-03-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/storagecache/2024-03-01/skus" +``` + + +### Client Initialization + +```go +client := skus.NewSKUsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SKUsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/storagecache/2024-03-01/skus/client.go b/resource-manager/storagecache/2024-03-01/skus/client.go new file mode 100644 index 00000000000..d2fbc1d3af0 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/skus/client.go @@ -0,0 +1,26 @@ +package skus + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SKUsClient struct { + Client *resourcemanager.Client +} + +func NewSKUsClientWithBaseURI(sdkApi sdkEnv.Api) (*SKUsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "skus", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SKUsClient: %+v", err) + } + + return &SKUsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/storagecache/2024-03-01/skus/constants.go b/resource-manager/storagecache/2024-03-01/skus/constants.go new file mode 100644 index 00000000000..e9d99b2352d --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/skus/constants.go @@ -0,0 +1,51 @@ +package skus + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReasonCode string + +const ( + ReasonCodeNotAvailableForSubscription ReasonCode = "NotAvailableForSubscription" + ReasonCodeQuotaId ReasonCode = "QuotaId" +) + +func PossibleValuesForReasonCode() []string { + return []string{ + string(ReasonCodeNotAvailableForSubscription), + string(ReasonCodeQuotaId), + } +} + +func (s *ReasonCode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseReasonCode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseReasonCode(input string) (*ReasonCode, error) { + vals := map[string]ReasonCode{ + "notavailableforsubscription": ReasonCodeNotAvailableForSubscription, + "quotaid": ReasonCodeQuotaId, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ReasonCode(input) + return &out, nil +} diff --git a/resource-manager/storagecache/2024-03-01/skus/method_list.go b/resource-manager/storagecache/2024-03-01/skus/method_list.go new file mode 100644 index 00000000000..c585e2159a8 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/skus/method_list.go @@ -0,0 +1,92 @@ +package skus + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// 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 + OData *odata.OData + Model *[]ResourceSku +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ResourceSku +} + +// List ... +func (c SKUsClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.StorageCache/skus", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ResourceSku `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c SKUsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ResourceSkuOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SKUsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ResourceSkuOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ResourceSku, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/storagecache/2024-03-01/skus/model_resourcesku.go b/resource-manager/storagecache/2024-03-01/skus/model_resourcesku.go new file mode 100644 index 00000000000..75091310415 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/skus/model_resourcesku.go @@ -0,0 +1,13 @@ +package skus + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceSku struct { + Capabilities *[]ResourceSkuCapabilities `json:"capabilities,omitempty"` + LocationInfo *[]ResourceSkuLocationInfo `json:"locationInfo,omitempty"` + Locations *[]string `json:"locations,omitempty"` + Name *string `json:"name,omitempty"` + ResourceType *string `json:"resourceType,omitempty"` + Restrictions *[]Restriction `json:"restrictions,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/skus/model_resourceskucapabilities.go b/resource-manager/storagecache/2024-03-01/skus/model_resourceskucapabilities.go new file mode 100644 index 00000000000..6dc852fca30 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/skus/model_resourceskucapabilities.go @@ -0,0 +1,9 @@ +package skus + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceSkuCapabilities struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/skus/model_resourceskulocationinfo.go b/resource-manager/storagecache/2024-03-01/skus/model_resourceskulocationinfo.go new file mode 100644 index 00000000000..2cee5ed675b --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/skus/model_resourceskulocationinfo.go @@ -0,0 +1,13 @@ +package skus + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceSkuLocationInfo struct { + Location *string `json:"location,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/skus/model_restriction.go b/resource-manager/storagecache/2024-03-01/skus/model_restriction.go new file mode 100644 index 00000000000..a0bb9517284 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/skus/model_restriction.go @@ -0,0 +1,10 @@ +package skus + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Restriction struct { + ReasonCode *ReasonCode `json:"reasonCode,omitempty"` + Type *string `json:"type,omitempty"` + Values *[]string `json:"values,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/skus/predicates.go b/resource-manager/storagecache/2024-03-01/skus/predicates.go new file mode 100644 index 00000000000..4d072f2f035 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/skus/predicates.go @@ -0,0 +1,22 @@ +package skus + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceSkuOperationPredicate struct { + Name *string + ResourceType *string +} + +func (p ResourceSkuOperationPredicate) Matches(input ResourceSku) bool { + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.ResourceType != nil && (input.ResourceType == nil || *p.ResourceType != *input.ResourceType) { + return false + } + + return true +} diff --git a/resource-manager/storagecache/2024-03-01/skus/version.go b/resource-manager/storagecache/2024-03-01/skus/version.go new file mode 100644 index 00000000000..6e61f75cb9f --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/skus/version.go @@ -0,0 +1,12 @@ +package skus + +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 = "2024-03-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/skus/%s", defaultApiVersion) +} diff --git a/resource-manager/storagecache/2024-03-01/storagetargets/README.md b/resource-manager/storagecache/2024-03-01/storagetargets/README.md new file mode 100644 index 00000000000..306567f45af --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/storagetargets/README.md @@ -0,0 +1,154 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/storagecache/2024-03-01/storagetargets` Documentation + +The `storagetargets` SDK allows for interaction with the Azure Resource Manager Service `storagecache` (API Version `2024-03-01`). + +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/storagecache/2024-03-01/storagetargets" +``` + + +### Client Initialization + +```go +client := storagetargets.NewStorageTargetsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `StorageTargetsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := storagetargets.NewStorageTargetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cacheValue", "storageTargetValue") + +payload := storagetargets.StorageTarget{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `StorageTargetsClient.Delete` + +```go +ctx := context.TODO() +id := storagetargets.NewStorageTargetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cacheValue", "storageTargetValue") + +if err := client.DeleteThenPoll(ctx, id, storagetargets.DefaultDeleteOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `StorageTargetsClient.DnsRefresh` + +```go +ctx := context.TODO() +id := storagetargets.NewStorageTargetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cacheValue", "storageTargetValue") + +if err := client.DnsRefreshThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `StorageTargetsClient.Get` + +```go +ctx := context.TODO() +id := storagetargets.NewStorageTargetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cacheValue", "storageTargetValue") + +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: `StorageTargetsClient.ListByCache` + +```go +ctx := context.TODO() +id := storagetargets.NewCacheID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cacheValue") + +// alternatively `client.ListByCache(ctx, id)` can be used to do batched pagination +items, err := client.ListByCacheComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StorageTargetsClient.RestoreDefaults` + +```go +ctx := context.TODO() +id := storagetargets.NewStorageTargetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cacheValue", "storageTargetValue") + +if err := client.RestoreDefaultsThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `StorageTargetsClient.StorageTargetFlush` + +```go +ctx := context.TODO() +id := storagetargets.NewStorageTargetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cacheValue", "storageTargetValue") + +if err := client.StorageTargetFlushThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `StorageTargetsClient.StorageTargetInvalidate` + +```go +ctx := context.TODO() +id := storagetargets.NewStorageTargetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cacheValue", "storageTargetValue") + +if err := client.StorageTargetInvalidateThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `StorageTargetsClient.StorageTargetResume` + +```go +ctx := context.TODO() +id := storagetargets.NewStorageTargetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cacheValue", "storageTargetValue") + +if err := client.StorageTargetResumeThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `StorageTargetsClient.StorageTargetSuspend` + +```go +ctx := context.TODO() +id := storagetargets.NewStorageTargetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cacheValue", "storageTargetValue") + +if err := client.StorageTargetSuspendThenPoll(ctx, id); err != nil { + // handle the error +} +``` diff --git a/resource-manager/storagecache/2024-03-01/storagetargets/client.go b/resource-manager/storagecache/2024-03-01/storagetargets/client.go new file mode 100644 index 00000000000..06219399bc4 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/storagetargets/client.go @@ -0,0 +1,26 @@ +package storagetargets + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageTargetsClient struct { + Client *resourcemanager.Client +} + +func NewStorageTargetsClientWithBaseURI(sdkApi sdkEnv.Api) (*StorageTargetsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "storagetargets", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating StorageTargetsClient: %+v", err) + } + + return &StorageTargetsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/storagecache/2024-03-01/storagetargets/constants.go b/resource-manager/storagecache/2024-03-01/storagetargets/constants.go new file mode 100644 index 00000000000..c20c47b145f --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/storagetargets/constants.go @@ -0,0 +1,157 @@ +package storagetargets + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OperationalStateType string + +const ( + OperationalStateTypeBusy OperationalStateType = "Busy" + OperationalStateTypeFlushing OperationalStateType = "Flushing" + OperationalStateTypeReady OperationalStateType = "Ready" + OperationalStateTypeSuspended OperationalStateType = "Suspended" +) + +func PossibleValuesForOperationalStateType() []string { + return []string{ + string(OperationalStateTypeBusy), + string(OperationalStateTypeFlushing), + string(OperationalStateTypeReady), + string(OperationalStateTypeSuspended), + } +} + +func (s *OperationalStateType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOperationalStateType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOperationalStateType(input string) (*OperationalStateType, error) { + vals := map[string]OperationalStateType{ + "busy": OperationalStateTypeBusy, + "flushing": OperationalStateTypeFlushing, + "ready": OperationalStateTypeReady, + "suspended": OperationalStateTypeSuspended, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OperationalStateType(input) + return &out, nil +} + +type ProvisioningStateType string + +const ( + ProvisioningStateTypeCanceled ProvisioningStateType = "Canceled" + ProvisioningStateTypeCreating ProvisioningStateType = "Creating" + ProvisioningStateTypeDeleting ProvisioningStateType = "Deleting" + ProvisioningStateTypeFailed ProvisioningStateType = "Failed" + ProvisioningStateTypeSucceeded ProvisioningStateType = "Succeeded" + ProvisioningStateTypeUpdating ProvisioningStateType = "Updating" +) + +func PossibleValuesForProvisioningStateType() []string { + return []string{ + string(ProvisioningStateTypeCanceled), + string(ProvisioningStateTypeCreating), + string(ProvisioningStateTypeDeleting), + string(ProvisioningStateTypeFailed), + string(ProvisioningStateTypeSucceeded), + string(ProvisioningStateTypeUpdating), + } +} + +func (s *ProvisioningStateType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningStateType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningStateType(input string) (*ProvisioningStateType, error) { + vals := map[string]ProvisioningStateType{ + "canceled": ProvisioningStateTypeCanceled, + "creating": ProvisioningStateTypeCreating, + "deleting": ProvisioningStateTypeDeleting, + "failed": ProvisioningStateTypeFailed, + "succeeded": ProvisioningStateTypeSucceeded, + "updating": ProvisioningStateTypeUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningStateType(input) + return &out, nil +} + +type StorageTargetType string + +const ( + StorageTargetTypeBlobNfs StorageTargetType = "blobNfs" + StorageTargetTypeClfs StorageTargetType = "clfs" + StorageTargetTypeNfsThree StorageTargetType = "nfs3" + StorageTargetTypeUnknown StorageTargetType = "unknown" +) + +func PossibleValuesForStorageTargetType() []string { + return []string{ + string(StorageTargetTypeBlobNfs), + string(StorageTargetTypeClfs), + string(StorageTargetTypeNfsThree), + string(StorageTargetTypeUnknown), + } +} + +func (s *StorageTargetType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStorageTargetType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStorageTargetType(input string) (*StorageTargetType, error) { + vals := map[string]StorageTargetType{ + "blobnfs": StorageTargetTypeBlobNfs, + "clfs": StorageTargetTypeClfs, + "nfs3": StorageTargetTypeNfsThree, + "unknown": StorageTargetTypeUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StorageTargetType(input) + return &out, nil +} diff --git a/resource-manager/storagecache/2024-03-01/storagetargets/id_cache.go b/resource-manager/storagecache/2024-03-01/storagetargets/id_cache.go new file mode 100644 index 00000000000..58ed3d8eda6 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/storagetargets/id_cache.go @@ -0,0 +1,130 @@ +package storagetargets + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CacheId{}) +} + +var _ resourceids.ResourceId = &CacheId{} + +// CacheId is a struct representing the Resource ID for a Cache +type CacheId struct { + SubscriptionId string + ResourceGroupName string + CacheName string +} + +// NewCacheID returns a new CacheId struct +func NewCacheID(subscriptionId string, resourceGroupName string, cacheName string) CacheId { + return CacheId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CacheName: cacheName, + } +} + +// ParseCacheID parses 'input' into a CacheId +func ParseCacheID(input string) (*CacheId, error) { + parser := resourceids.NewParserFromResourceIdType(&CacheId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CacheId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCacheIDInsensitively parses 'input' case-insensitively into a CacheId +// note: this method should only be used for API response data and not user input +func ParseCacheIDInsensitively(input string) (*CacheId, error) { + parser := resourceids.NewParserFromResourceIdType(&CacheId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CacheId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CacheId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CacheName, ok = input.Parsed["cacheName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "cacheName", input) + } + + return nil +} + +// ValidateCacheID checks that 'input' can be parsed as a Cache ID +func ValidateCacheID(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 := ParseCacheID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Cache ID +func (id CacheId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.StorageCache/caches/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CacheName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Cache ID +func (id CacheId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftStorageCache", "Microsoft.StorageCache", "Microsoft.StorageCache"), + resourceids.StaticSegment("staticCaches", "caches", "caches"), + resourceids.UserSpecifiedSegment("cacheName", "cacheValue"), + } +} + +// String returns a human-readable description of this Cache ID +func (id CacheId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cache Name: %q", id.CacheName), + } + return fmt.Sprintf("Cache (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/storagecache/2024-03-01/storagetargets/id_cache_test.go b/resource-manager/storagecache/2024-03-01/storagetargets/id_cache_test.go new file mode 100644 index 00000000000..20cc465bd5c --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/storagetargets/id_cache_test.go @@ -0,0 +1,282 @@ +package storagetargets + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &CacheId{} + +func TestNewCacheID(t *testing.T) { + id := NewCacheID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cacheValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.CacheName != "cacheValue" { + t.Fatalf("Expected %q but got %q for Segment 'CacheName'", id.CacheName, "cacheValue") + } +} + +func TestFormatCacheID(t *testing.T) { + actual := NewCacheID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cacheValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/caches/cacheValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCacheID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CacheId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/caches", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/caches/cacheValue", + Expected: &CacheId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CacheName: "cacheValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/caches/cacheValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCacheID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", 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.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CacheName != v.Expected.CacheName { + t.Fatalf("Expected %q but got %q for CacheName", v.Expected.CacheName, actual.CacheName) + } + + } +} + +func TestParseCacheIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CacheId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sToRaGeCaChE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/caches", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sToRaGeCaChE/cAcHeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/caches/cacheValue", + Expected: &CacheId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CacheName: "cacheValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/caches/cacheValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sToRaGeCaChE/cAcHeS/cAcHeVaLuE", + Expected: &CacheId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CacheName: "cAcHeVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sToRaGeCaChE/cAcHeS/cAcHeVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCacheIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", 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.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CacheName != v.Expected.CacheName { + t.Fatalf("Expected %q but got %q for CacheName", v.Expected.CacheName, actual.CacheName) + } + + } +} + +func TestSegmentsForCacheId(t *testing.T) { + segments := CacheId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CacheId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/storagecache/2024-03-01/storagetargets/id_storagetarget.go b/resource-manager/storagecache/2024-03-01/storagetargets/id_storagetarget.go new file mode 100644 index 00000000000..a7fa0e89afc --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/storagetargets/id_storagetarget.go @@ -0,0 +1,139 @@ +package storagetargets + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&StorageTargetId{}) +} + +var _ resourceids.ResourceId = &StorageTargetId{} + +// StorageTargetId is a struct representing the Resource ID for a Storage Target +type StorageTargetId struct { + SubscriptionId string + ResourceGroupName string + CacheName string + StorageTargetName string +} + +// NewStorageTargetID returns a new StorageTargetId struct +func NewStorageTargetID(subscriptionId string, resourceGroupName string, cacheName string, storageTargetName string) StorageTargetId { + return StorageTargetId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CacheName: cacheName, + StorageTargetName: storageTargetName, + } +} + +// ParseStorageTargetID parses 'input' into a StorageTargetId +func ParseStorageTargetID(input string) (*StorageTargetId, error) { + parser := resourceids.NewParserFromResourceIdType(&StorageTargetId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StorageTargetId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseStorageTargetIDInsensitively parses 'input' case-insensitively into a StorageTargetId +// note: this method should only be used for API response data and not user input +func ParseStorageTargetIDInsensitively(input string) (*StorageTargetId, error) { + parser := resourceids.NewParserFromResourceIdType(&StorageTargetId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StorageTargetId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *StorageTargetId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CacheName, ok = input.Parsed["cacheName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "cacheName", input) + } + + if id.StorageTargetName, ok = input.Parsed["storageTargetName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "storageTargetName", input) + } + + return nil +} + +// ValidateStorageTargetID checks that 'input' can be parsed as a Storage Target ID +func ValidateStorageTargetID(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 := ParseStorageTargetID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Storage Target ID +func (id StorageTargetId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.StorageCache/caches/%s/storageTargets/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CacheName, id.StorageTargetName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Storage Target ID +func (id StorageTargetId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftStorageCache", "Microsoft.StorageCache", "Microsoft.StorageCache"), + resourceids.StaticSegment("staticCaches", "caches", "caches"), + resourceids.UserSpecifiedSegment("cacheName", "cacheValue"), + resourceids.StaticSegment("staticStorageTargets", "storageTargets", "storageTargets"), + resourceids.UserSpecifiedSegment("storageTargetName", "storageTargetValue"), + } +} + +// String returns a human-readable description of this Storage Target ID +func (id StorageTargetId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cache Name: %q", id.CacheName), + fmt.Sprintf("Storage Target Name: %q", id.StorageTargetName), + } + return fmt.Sprintf("Storage Target (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/storagecache/2024-03-01/storagetargets/id_storagetarget_test.go b/resource-manager/storagecache/2024-03-01/storagetargets/id_storagetarget_test.go new file mode 100644 index 00000000000..fb699a3633a --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/storagetargets/id_storagetarget_test.go @@ -0,0 +1,327 @@ +package storagetargets + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &StorageTargetId{} + +func TestNewStorageTargetID(t *testing.T) { + id := NewStorageTargetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cacheValue", "storageTargetValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.CacheName != "cacheValue" { + t.Fatalf("Expected %q but got %q for Segment 'CacheName'", id.CacheName, "cacheValue") + } + + if id.StorageTargetName != "storageTargetValue" { + t.Fatalf("Expected %q but got %q for Segment 'StorageTargetName'", id.StorageTargetName, "storageTargetValue") + } +} + +func TestFormatStorageTargetID(t *testing.T) { + actual := NewStorageTargetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cacheValue", "storageTargetValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/caches/cacheValue/storageTargets/storageTargetValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseStorageTargetID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *StorageTargetId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/caches", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/caches/cacheValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/caches/cacheValue/storageTargets", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/caches/cacheValue/storageTargets/storageTargetValue", + Expected: &StorageTargetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CacheName: "cacheValue", + StorageTargetName: "storageTargetValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/caches/cacheValue/storageTargets/storageTargetValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseStorageTargetID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", 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.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CacheName != v.Expected.CacheName { + t.Fatalf("Expected %q but got %q for CacheName", v.Expected.CacheName, actual.CacheName) + } + + if actual.StorageTargetName != v.Expected.StorageTargetName { + t.Fatalf("Expected %q but got %q for StorageTargetName", v.Expected.StorageTargetName, actual.StorageTargetName) + } + + } +} + +func TestParseStorageTargetIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *StorageTargetId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sToRaGeCaChE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/caches", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sToRaGeCaChE/cAcHeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/caches/cacheValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sToRaGeCaChE/cAcHeS/cAcHeVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/caches/cacheValue/storageTargets", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sToRaGeCaChE/cAcHeS/cAcHeVaLuE/sToRaGeTaRgEtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/caches/cacheValue/storageTargets/storageTargetValue", + Expected: &StorageTargetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CacheName: "cacheValue", + StorageTargetName: "storageTargetValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.StorageCache/caches/cacheValue/storageTargets/storageTargetValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sToRaGeCaChE/cAcHeS/cAcHeVaLuE/sToRaGeTaRgEtS/sToRaGeTaRgEtVaLuE", + Expected: &StorageTargetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CacheName: "cAcHeVaLuE", + StorageTargetName: "sToRaGeTaRgEtVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sToRaGeCaChE/cAcHeS/cAcHeVaLuE/sToRaGeTaRgEtS/sToRaGeTaRgEtVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseStorageTargetIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", 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.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CacheName != v.Expected.CacheName { + t.Fatalf("Expected %q but got %q for CacheName", v.Expected.CacheName, actual.CacheName) + } + + if actual.StorageTargetName != v.Expected.StorageTargetName { + t.Fatalf("Expected %q but got %q for StorageTargetName", v.Expected.StorageTargetName, actual.StorageTargetName) + } + + } +} + +func TestSegmentsForStorageTargetId(t *testing.T) { + segments := StorageTargetId{}.Segments() + if len(segments) == 0 { + t.Fatalf("StorageTargetId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/storagecache/2024-03-01/storagetargets/method_createorupdate.go b/resource-manager/storagecache/2024-03-01/storagetargets/method_createorupdate.go new file mode 100644 index 00000000000..dfc8744903e --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/storagetargets/method_createorupdate.go @@ -0,0 +1,76 @@ +package storagetargets + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// 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 { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *StorageTarget +} + +// CreateOrUpdate ... +func (c StorageTargetsClient) CreateOrUpdate(ctx context.Context, id StorageTargetId, input StorageTarget) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c StorageTargetsClient) CreateOrUpdateThenPoll(ctx context.Context, id StorageTargetId, input StorageTarget) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/storagecache/2024-03-01/storagetargets/method_delete.go b/resource-manager/storagecache/2024-03-01/storagetargets/method_delete.go new file mode 100644 index 00000000000..504473e8fd3 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/storagetargets/method_delete.go @@ -0,0 +1,99 @@ +package storagetargets + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// 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 { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + Force *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Force != nil { + out.Append("force", fmt.Sprintf("%v", *o.Force)) + } + return &out +} + +// Delete ... +func (c StorageTargetsClient) Delete(ctx context.Context, id StorageTargetId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c StorageTargetsClient) DeleteThenPoll(ctx context.Context, id StorageTargetId, options DeleteOperationOptions) error { + result, err := c.Delete(ctx, id, options) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/storagecache/2024-03-01/storagetargets/method_dnsrefresh.go b/resource-manager/storagecache/2024-03-01/storagetargets/method_dnsrefresh.go new file mode 100644 index 00000000000..bbee43e3e1a --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/storagetargets/method_dnsrefresh.go @@ -0,0 +1,70 @@ +package storagetargets + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DnsRefreshOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DnsRefresh ... +func (c StorageTargetsClient) DnsRefresh(ctx context.Context, id StorageTargetId) (result DnsRefreshOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/dnsRefresh", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DnsRefreshThenPoll performs DnsRefresh then polls until it's completed +func (c StorageTargetsClient) DnsRefreshThenPoll(ctx context.Context, id StorageTargetId) error { + result, err := c.DnsRefresh(ctx, id) + if err != nil { + return fmt.Errorf("performing DnsRefresh: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DnsRefresh: %+v", err) + } + + return nil +} diff --git a/resource-manager/storagecache/2024-03-01/storagetargets/method_get.go b/resource-manager/storagecache/2024-03-01/storagetargets/method_get.go new file mode 100644 index 00000000000..c96eec97823 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/storagetargets/method_get.go @@ -0,0 +1,54 @@ +package storagetargets + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// 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 + OData *odata.OData + Model *StorageTarget +} + +// Get ... +func (c StorageTargetsClient) Get(ctx context.Context, id StorageTargetId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StorageTarget + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/storagecache/2024-03-01/storagetargets/method_listbycache.go b/resource-manager/storagecache/2024-03-01/storagetargets/method_listbycache.go new file mode 100644 index 00000000000..7950ff031fc --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/storagetargets/method_listbycache.go @@ -0,0 +1,91 @@ +package storagetargets + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByCacheOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StorageTarget +} + +type ListByCacheCompleteResult struct { + LatestHttpResponse *http.Response + Items []StorageTarget +} + +// ListByCache ... +func (c StorageTargetsClient) ListByCache(ctx context.Context, id CacheId) (result ListByCacheOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/storageTargets", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StorageTarget `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByCacheComplete retrieves all the results into a single object +func (c StorageTargetsClient) ListByCacheComplete(ctx context.Context, id CacheId) (ListByCacheCompleteResult, error) { + return c.ListByCacheCompleteMatchingPredicate(ctx, id, StorageTargetOperationPredicate{}) +} + +// ListByCacheCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StorageTargetsClient) ListByCacheCompleteMatchingPredicate(ctx context.Context, id CacheId, predicate StorageTargetOperationPredicate) (result ListByCacheCompleteResult, err error) { + items := make([]StorageTarget, 0) + + resp, err := c.ListByCache(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByCacheCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/storagecache/2024-03-01/storagetargets/method_restoredefaults.go b/resource-manager/storagecache/2024-03-01/storagetargets/method_restoredefaults.go new file mode 100644 index 00000000000..e04112416ca --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/storagetargets/method_restoredefaults.go @@ -0,0 +1,70 @@ +package storagetargets + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestoreDefaultsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RestoreDefaults ... +func (c StorageTargetsClient) RestoreDefaults(ctx context.Context, id StorageTargetId) (result RestoreDefaultsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restoreDefaults", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RestoreDefaultsThenPoll performs RestoreDefaults then polls until it's completed +func (c StorageTargetsClient) RestoreDefaultsThenPoll(ctx context.Context, id StorageTargetId) error { + result, err := c.RestoreDefaults(ctx, id) + if err != nil { + return fmt.Errorf("performing RestoreDefaults: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RestoreDefaults: %+v", err) + } + + return nil +} diff --git a/resource-manager/storagecache/2024-03-01/storagetargets/method_storagetargetflush.go b/resource-manager/storagecache/2024-03-01/storagetargets/method_storagetargetflush.go new file mode 100644 index 00000000000..5efd48cf8fb --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/storagetargets/method_storagetargetflush.go @@ -0,0 +1,71 @@ +package storagetargets + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageTargetFlushOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// StorageTargetFlush ... +func (c StorageTargetsClient) StorageTargetFlush(ctx context.Context, id StorageTargetId) (result StorageTargetFlushOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/flush", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// StorageTargetFlushThenPoll performs StorageTargetFlush then polls until it's completed +func (c StorageTargetsClient) StorageTargetFlushThenPoll(ctx context.Context, id StorageTargetId) error { + result, err := c.StorageTargetFlush(ctx, id) + if err != nil { + return fmt.Errorf("performing StorageTargetFlush: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after StorageTargetFlush: %+v", err) + } + + return nil +} diff --git a/resource-manager/storagecache/2024-03-01/storagetargets/method_storagetargetinvalidate.go b/resource-manager/storagecache/2024-03-01/storagetargets/method_storagetargetinvalidate.go new file mode 100644 index 00000000000..35f6d7277f4 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/storagetargets/method_storagetargetinvalidate.go @@ -0,0 +1,71 @@ +package storagetargets + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageTargetInvalidateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// StorageTargetInvalidate ... +func (c StorageTargetsClient) StorageTargetInvalidate(ctx context.Context, id StorageTargetId) (result StorageTargetInvalidateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/invalidate", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// StorageTargetInvalidateThenPoll performs StorageTargetInvalidate then polls until it's completed +func (c StorageTargetsClient) StorageTargetInvalidateThenPoll(ctx context.Context, id StorageTargetId) error { + result, err := c.StorageTargetInvalidate(ctx, id) + if err != nil { + return fmt.Errorf("performing StorageTargetInvalidate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after StorageTargetInvalidate: %+v", err) + } + + return nil +} diff --git a/resource-manager/storagecache/2024-03-01/storagetargets/method_storagetargetresume.go b/resource-manager/storagecache/2024-03-01/storagetargets/method_storagetargetresume.go new file mode 100644 index 00000000000..92af63d5779 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/storagetargets/method_storagetargetresume.go @@ -0,0 +1,71 @@ +package storagetargets + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageTargetResumeOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// StorageTargetResume ... +func (c StorageTargetsClient) StorageTargetResume(ctx context.Context, id StorageTargetId) (result StorageTargetResumeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resume", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// StorageTargetResumeThenPoll performs StorageTargetResume then polls until it's completed +func (c StorageTargetsClient) StorageTargetResumeThenPoll(ctx context.Context, id StorageTargetId) error { + result, err := c.StorageTargetResume(ctx, id) + if err != nil { + return fmt.Errorf("performing StorageTargetResume: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after StorageTargetResume: %+v", err) + } + + return nil +} diff --git a/resource-manager/storagecache/2024-03-01/storagetargets/method_storagetargetsuspend.go b/resource-manager/storagecache/2024-03-01/storagetargets/method_storagetargetsuspend.go new file mode 100644 index 00000000000..72981e955bb --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/storagetargets/method_storagetargetsuspend.go @@ -0,0 +1,71 @@ +package storagetargets + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageTargetSuspendOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// StorageTargetSuspend ... +func (c StorageTargetsClient) StorageTargetSuspend(ctx context.Context, id StorageTargetId) (result StorageTargetSuspendOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/suspend", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// StorageTargetSuspendThenPoll performs StorageTargetSuspend then polls until it's completed +func (c StorageTargetsClient) StorageTargetSuspendThenPoll(ctx context.Context, id StorageTargetId) error { + result, err := c.StorageTargetSuspend(ctx, id) + if err != nil { + return fmt.Errorf("performing StorageTargetSuspend: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after StorageTargetSuspend: %+v", err) + } + + return nil +} diff --git a/resource-manager/storagecache/2024-03-01/storagetargets/model_blobnfstarget.go b/resource-manager/storagecache/2024-03-01/storagetargets/model_blobnfstarget.go new file mode 100644 index 00000000000..0ae0d625095 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/storagetargets/model_blobnfstarget.go @@ -0,0 +1,11 @@ +package storagetargets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BlobNfsTarget struct { + Target *string `json:"target,omitempty"` + UsageModel *string `json:"usageModel,omitempty"` + VerificationTimer *int64 `json:"verificationTimer,omitempty"` + WriteBackTimer *int64 `json:"writeBackTimer,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/storagetargets/model_clfstarget.go b/resource-manager/storagecache/2024-03-01/storagetargets/model_clfstarget.go new file mode 100644 index 00000000000..c9be9c2c727 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/storagetargets/model_clfstarget.go @@ -0,0 +1,8 @@ +package storagetargets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClfsTarget struct { + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/storagetargets/model_namespacejunction.go b/resource-manager/storagecache/2024-03-01/storagetargets/model_namespacejunction.go new file mode 100644 index 00000000000..4a8c7fb416f --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/storagetargets/model_namespacejunction.go @@ -0,0 +1,11 @@ +package storagetargets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NamespaceJunction struct { + NamespacePath *string `json:"namespacePath,omitempty"` + NfsAccessPolicy *string `json:"nfsAccessPolicy,omitempty"` + NfsExport *string `json:"nfsExport,omitempty"` + TargetPath *string `json:"targetPath,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/storagetargets/model_nfs3target.go b/resource-manager/storagecache/2024-03-01/storagetargets/model_nfs3target.go new file mode 100644 index 00000000000..356a47c8fef --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/storagetargets/model_nfs3target.go @@ -0,0 +1,11 @@ +package storagetargets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Nfs3Target struct { + Target *string `json:"target,omitempty"` + UsageModel *string `json:"usageModel,omitempty"` + VerificationTimer *int64 `json:"verificationTimer,omitempty"` + WriteBackTimer *int64 `json:"writeBackTimer,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/storagetargets/model_storagetarget.go b/resource-manager/storagecache/2024-03-01/storagetargets/model_storagetarget.go new file mode 100644 index 00000000000..f2ade44f92e --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/storagetargets/model_storagetarget.go @@ -0,0 +1,17 @@ +package storagetargets + +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 StorageTarget struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StorageTargetProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/storagetargets/model_storagetargetproperties.go b/resource-manager/storagecache/2024-03-01/storagetargets/model_storagetargetproperties.go new file mode 100644 index 00000000000..e53a0d72ddb --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/storagetargets/model_storagetargetproperties.go @@ -0,0 +1,16 @@ +package storagetargets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageTargetProperties struct { + AllocationPercentage *int64 `json:"allocationPercentage,omitempty"` + BlobNfs *BlobNfsTarget `json:"blobNfs,omitempty"` + Clfs *ClfsTarget `json:"clfs,omitempty"` + Junctions *[]NamespaceJunction `json:"junctions,omitempty"` + Nfs3 *Nfs3Target `json:"nfs3,omitempty"` + ProvisioningState *ProvisioningStateType `json:"provisioningState,omitempty"` + State *OperationalStateType `json:"state,omitempty"` + TargetType StorageTargetType `json:"targetType"` + Unknown *UnknownTarget `json:"unknown,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/storagetargets/model_unknowntarget.go b/resource-manager/storagecache/2024-03-01/storagetargets/model_unknowntarget.go new file mode 100644 index 00000000000..546e0cbdf77 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/storagetargets/model_unknowntarget.go @@ -0,0 +1,8 @@ +package storagetargets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UnknownTarget struct { + Attributes *map[string]string `json:"attributes,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/storagetargets/predicates.go b/resource-manager/storagecache/2024-03-01/storagetargets/predicates.go new file mode 100644 index 00000000000..30c9e142fd1 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/storagetargets/predicates.go @@ -0,0 +1,32 @@ +package storagetargets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageTargetOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p StorageTargetOperationPredicate) Matches(input StorageTarget) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + 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/resource-manager/storagecache/2024-03-01/storagetargets/version.go b/resource-manager/storagecache/2024-03-01/storagetargets/version.go new file mode 100644 index 00000000000..370c39c735b --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/storagetargets/version.go @@ -0,0 +1,12 @@ +package storagetargets + +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 = "2024-03-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/storagetargets/%s", defaultApiVersion) +} diff --git a/resource-manager/storagecache/2024-03-01/usagemodels/README.md b/resource-manager/storagecache/2024-03-01/usagemodels/README.md new file mode 100644 index 00000000000..a262760b1f9 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/usagemodels/README.md @@ -0,0 +1,38 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/storagecache/2024-03-01/usagemodels` Documentation + +The `usagemodels` SDK allows for interaction with the Azure Resource Manager Service `storagecache` (API Version `2024-03-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/storagecache/2024-03-01/usagemodels" +``` + + +### Client Initialization + +```go +client := usagemodels.NewUsageModelsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `UsageModelsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/storagecache/2024-03-01/usagemodels/client.go b/resource-manager/storagecache/2024-03-01/usagemodels/client.go new file mode 100644 index 00000000000..1755ed55724 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/usagemodels/client.go @@ -0,0 +1,26 @@ +package usagemodels + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UsageModelsClient struct { + Client *resourcemanager.Client +} + +func NewUsageModelsClientWithBaseURI(sdkApi sdkEnv.Api) (*UsageModelsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "usagemodels", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating UsageModelsClient: %+v", err) + } + + return &UsageModelsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/storagecache/2024-03-01/usagemodels/method_list.go b/resource-manager/storagecache/2024-03-01/usagemodels/method_list.go new file mode 100644 index 00000000000..014b0c7e1e1 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/usagemodels/method_list.go @@ -0,0 +1,92 @@ +package usagemodels + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// 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 + OData *odata.OData + Model *[]UsageModel +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []UsageModel +} + +// List ... +func (c UsageModelsClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.StorageCache/usageModels", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]UsageModel `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c UsageModelsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, UsageModelOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c UsageModelsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate UsageModelOperationPredicate) (result ListCompleteResult, err error) { + items := make([]UsageModel, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/storagecache/2024-03-01/usagemodels/model_usagemodel.go b/resource-manager/storagecache/2024-03-01/usagemodels/model_usagemodel.go new file mode 100644 index 00000000000..f75ff0f1347 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/usagemodels/model_usagemodel.go @@ -0,0 +1,10 @@ +package usagemodels + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UsageModel struct { + Display *UsageModelDisplay `json:"display,omitempty"` + ModelName *string `json:"modelName,omitempty"` + TargetType *string `json:"targetType,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/usagemodels/model_usagemodeldisplay.go b/resource-manager/storagecache/2024-03-01/usagemodels/model_usagemodeldisplay.go new file mode 100644 index 00000000000..ce9b97bc2ee --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/usagemodels/model_usagemodeldisplay.go @@ -0,0 +1,8 @@ +package usagemodels + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UsageModelDisplay struct { + Description *string `json:"description,omitempty"` +} diff --git a/resource-manager/storagecache/2024-03-01/usagemodels/predicates.go b/resource-manager/storagecache/2024-03-01/usagemodels/predicates.go new file mode 100644 index 00000000000..7e151181aec --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/usagemodels/predicates.go @@ -0,0 +1,22 @@ +package usagemodels + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UsageModelOperationPredicate struct { + ModelName *string + TargetType *string +} + +func (p UsageModelOperationPredicate) Matches(input UsageModel) bool { + + if p.ModelName != nil && (input.ModelName == nil || *p.ModelName != *input.ModelName) { + return false + } + + if p.TargetType != nil && (input.TargetType == nil || *p.TargetType != *input.TargetType) { + return false + } + + return true +} diff --git a/resource-manager/storagecache/2024-03-01/usagemodels/version.go b/resource-manager/storagecache/2024-03-01/usagemodels/version.go new file mode 100644 index 00000000000..77bb1b4a5a3 --- /dev/null +++ b/resource-manager/storagecache/2024-03-01/usagemodels/version.go @@ -0,0 +1,12 @@ +package usagemodels + +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 = "2024-03-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/usagemodels/%s", defaultApiVersion) +}