diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/README.md b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/README.md new file mode 100644 index 00000000000..f010f0e91de --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/README.md @@ -0,0 +1,99 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups` Documentation + +The `autonomousdatabasebackups` SDK allows for interaction with the Azure Resource Manager Service `oracledatabase` (API Version `2024-06-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/oracledatabase/2024-06-01/autonomousdatabasebackups" +``` + + +### Client Initialization + +```go +client := autonomousdatabasebackups.NewAutonomousDatabaseBackupsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AutonomousDatabaseBackupsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := autonomousdatabasebackups.NewAutonomousDatabaseBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "autonomousDatabaseValue", "autonomousDatabaseBackupValue") + +payload := autonomousdatabasebackups.AutonomousDatabaseBackup{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AutonomousDatabaseBackupsClient.Delete` + +```go +ctx := context.TODO() +id := autonomousdatabasebackups.NewAutonomousDatabaseBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "autonomousDatabaseValue", "autonomousDatabaseBackupValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `AutonomousDatabaseBackupsClient.Get` + +```go +ctx := context.TODO() +id := autonomousdatabasebackups.NewAutonomousDatabaseBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "autonomousDatabaseValue", "autonomousDatabaseBackupValue") + +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: `AutonomousDatabaseBackupsClient.ListByAutonomousDatabase` + +```go +ctx := context.TODO() +id := autonomousdatabasebackups.NewAutonomousDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "autonomousDatabaseValue") + +// alternatively `client.ListByAutonomousDatabase(ctx, id)` can be used to do batched pagination +items, err := client.ListByAutonomousDatabaseComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AutonomousDatabaseBackupsClient.Update` + +```go +ctx := context.TODO() +id := autonomousdatabasebackups.NewAutonomousDatabaseBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "autonomousDatabaseValue", "autonomousDatabaseBackupValue") + +payload := autonomousdatabasebackups.AutonomousDatabaseBackupUpdate{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/client.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/client.go new file mode 100644 index 00000000000..d28226c6c84 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/client.go @@ -0,0 +1,26 @@ +package autonomousdatabasebackups + +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 AutonomousDatabaseBackupsClient struct { + Client *resourcemanager.Client +} + +func NewAutonomousDatabaseBackupsClientWithBaseURI(sdkApi sdkEnv.Api) (*AutonomousDatabaseBackupsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "autonomousdatabasebackups", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AutonomousDatabaseBackupsClient: %+v", err) + } + + return &AutonomousDatabaseBackupsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/constants.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/constants.go new file mode 100644 index 00000000000..95360d30614 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/constants.go @@ -0,0 +1,151 @@ +package autonomousdatabasebackups + +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 AutonomousDatabaseBackupLifecycleState string + +const ( + AutonomousDatabaseBackupLifecycleStateActive AutonomousDatabaseBackupLifecycleState = "Active" + AutonomousDatabaseBackupLifecycleStateCreating AutonomousDatabaseBackupLifecycleState = "Creating" + AutonomousDatabaseBackupLifecycleStateDeleting AutonomousDatabaseBackupLifecycleState = "Deleting" + AutonomousDatabaseBackupLifecycleStateFailed AutonomousDatabaseBackupLifecycleState = "Failed" + AutonomousDatabaseBackupLifecycleStateUpdating AutonomousDatabaseBackupLifecycleState = "Updating" +) + +func PossibleValuesForAutonomousDatabaseBackupLifecycleState() []string { + return []string{ + string(AutonomousDatabaseBackupLifecycleStateActive), + string(AutonomousDatabaseBackupLifecycleStateCreating), + string(AutonomousDatabaseBackupLifecycleStateDeleting), + string(AutonomousDatabaseBackupLifecycleStateFailed), + string(AutonomousDatabaseBackupLifecycleStateUpdating), + } +} + +func (s *AutonomousDatabaseBackupLifecycleState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutonomousDatabaseBackupLifecycleState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutonomousDatabaseBackupLifecycleState(input string) (*AutonomousDatabaseBackupLifecycleState, error) { + vals := map[string]AutonomousDatabaseBackupLifecycleState{ + "active": AutonomousDatabaseBackupLifecycleStateActive, + "creating": AutonomousDatabaseBackupLifecycleStateCreating, + "deleting": AutonomousDatabaseBackupLifecycleStateDeleting, + "failed": AutonomousDatabaseBackupLifecycleStateFailed, + "updating": AutonomousDatabaseBackupLifecycleStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutonomousDatabaseBackupLifecycleState(input) + return &out, nil +} + +type AutonomousDatabaseBackupType string + +const ( + AutonomousDatabaseBackupTypeFull AutonomousDatabaseBackupType = "Full" + AutonomousDatabaseBackupTypeIncremental AutonomousDatabaseBackupType = "Incremental" + AutonomousDatabaseBackupTypeLongTerm AutonomousDatabaseBackupType = "LongTerm" +) + +func PossibleValuesForAutonomousDatabaseBackupType() []string { + return []string{ + string(AutonomousDatabaseBackupTypeFull), + string(AutonomousDatabaseBackupTypeIncremental), + string(AutonomousDatabaseBackupTypeLongTerm), + } +} + +func (s *AutonomousDatabaseBackupType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutonomousDatabaseBackupType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutonomousDatabaseBackupType(input string) (*AutonomousDatabaseBackupType, error) { + vals := map[string]AutonomousDatabaseBackupType{ + "full": AutonomousDatabaseBackupTypeFull, + "incremental": AutonomousDatabaseBackupTypeIncremental, + "longterm": AutonomousDatabaseBackupTypeLongTerm, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutonomousDatabaseBackupType(input) + return &out, nil +} + +type AzureResourceProvisioningState string + +const ( + AzureResourceProvisioningStateCanceled AzureResourceProvisioningState = "Canceled" + AzureResourceProvisioningStateFailed AzureResourceProvisioningState = "Failed" + AzureResourceProvisioningStateProvisioning AzureResourceProvisioningState = "Provisioning" + AzureResourceProvisioningStateSucceeded AzureResourceProvisioningState = "Succeeded" +) + +func PossibleValuesForAzureResourceProvisioningState() []string { + return []string{ + string(AzureResourceProvisioningStateCanceled), + string(AzureResourceProvisioningStateFailed), + string(AzureResourceProvisioningStateProvisioning), + string(AzureResourceProvisioningStateSucceeded), + } +} + +func (s *AzureResourceProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureResourceProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureResourceProvisioningState(input string) (*AzureResourceProvisioningState, error) { + vals := map[string]AzureResourceProvisioningState{ + "canceled": AzureResourceProvisioningStateCanceled, + "failed": AzureResourceProvisioningStateFailed, + "provisioning": AzureResourceProvisioningStateProvisioning, + "succeeded": AzureResourceProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureResourceProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/id_autonomousdatabase.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/id_autonomousdatabase.go new file mode 100644 index 00000000000..ac451719a55 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/id_autonomousdatabase.go @@ -0,0 +1,130 @@ +package autonomousdatabasebackups + +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(&AutonomousDatabaseId{}) +} + +var _ resourceids.ResourceId = &AutonomousDatabaseId{} + +// AutonomousDatabaseId is a struct representing the Resource ID for a Autonomous Database +type AutonomousDatabaseId struct { + SubscriptionId string + ResourceGroupName string + AutonomousDatabaseName string +} + +// NewAutonomousDatabaseID returns a new AutonomousDatabaseId struct +func NewAutonomousDatabaseID(subscriptionId string, resourceGroupName string, autonomousDatabaseName string) AutonomousDatabaseId { + return AutonomousDatabaseId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + AutonomousDatabaseName: autonomousDatabaseName, + } +} + +// ParseAutonomousDatabaseID parses 'input' into a AutonomousDatabaseId +func ParseAutonomousDatabaseID(input string) (*AutonomousDatabaseId, error) { + parser := resourceids.NewParserFromResourceIdType(&AutonomousDatabaseId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AutonomousDatabaseId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAutonomousDatabaseIDInsensitively parses 'input' case-insensitively into a AutonomousDatabaseId +// note: this method should only be used for API response data and not user input +func ParseAutonomousDatabaseIDInsensitively(input string) (*AutonomousDatabaseId, error) { + parser := resourceids.NewParserFromResourceIdType(&AutonomousDatabaseId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AutonomousDatabaseId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AutonomousDatabaseId) 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.AutonomousDatabaseName, ok = input.Parsed["autonomousDatabaseName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "autonomousDatabaseName", input) + } + + return nil +} + +// ValidateAutonomousDatabaseID checks that 'input' can be parsed as a Autonomous Database ID +func ValidateAutonomousDatabaseID(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 := ParseAutonomousDatabaseID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Autonomous Database ID +func (id AutonomousDatabaseId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Oracle.Database/autonomousDatabases/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.AutonomousDatabaseName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Autonomous Database ID +func (id AutonomousDatabaseId) 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("staticOracleDatabase", "Oracle.Database", "Oracle.Database"), + resourceids.StaticSegment("staticAutonomousDatabases", "autonomousDatabases", "autonomousDatabases"), + resourceids.UserSpecifiedSegment("autonomousDatabaseName", "autonomousDatabaseValue"), + } +} + +// String returns a human-readable description of this Autonomous Database ID +func (id AutonomousDatabaseId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Autonomous Database Name: %q", id.AutonomousDatabaseName), + } + return fmt.Sprintf("Autonomous Database (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/id_autonomousdatabase_test.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/id_autonomousdatabase_test.go new file mode 100644 index 00000000000..2e757a94f86 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/id_autonomousdatabase_test.go @@ -0,0 +1,282 @@ +package autonomousdatabasebackups + +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 = &AutonomousDatabaseId{} + +func TestNewAutonomousDatabaseID(t *testing.T) { + id := NewAutonomousDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "autonomousDatabaseValue") + + 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.AutonomousDatabaseName != "autonomousDatabaseValue" { + t.Fatalf("Expected %q but got %q for Segment 'AutonomousDatabaseName'", id.AutonomousDatabaseName, "autonomousDatabaseValue") + } +} + +func TestFormatAutonomousDatabaseID(t *testing.T) { + actual := NewAutonomousDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "autonomousDatabaseValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/autonomousDatabases/autonomousDatabaseValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAutonomousDatabaseID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AutonomousDatabaseId + }{ + { + // 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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/autonomousDatabases", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/autonomousDatabases/autonomousDatabaseValue", + Expected: &AutonomousDatabaseId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + AutonomousDatabaseName: "autonomousDatabaseValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/autonomousDatabases/autonomousDatabaseValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAutonomousDatabaseID(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.AutonomousDatabaseName != v.Expected.AutonomousDatabaseName { + t.Fatalf("Expected %q but got %q for AutonomousDatabaseName", v.Expected.AutonomousDatabaseName, actual.AutonomousDatabaseName) + } + + } +} + +func TestParseAutonomousDatabaseIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AutonomousDatabaseId + }{ + { + // 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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/autonomousDatabases", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe/aUtOnOmOuSdAtAbAsEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/autonomousDatabases/autonomousDatabaseValue", + Expected: &AutonomousDatabaseId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + AutonomousDatabaseName: "autonomousDatabaseValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/autonomousDatabases/autonomousDatabaseValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe/aUtOnOmOuSdAtAbAsEs/aUtOnOmOuSdAtAbAsEvAlUe", + Expected: &AutonomousDatabaseId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + AutonomousDatabaseName: "aUtOnOmOuSdAtAbAsEvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe/aUtOnOmOuSdAtAbAsEs/aUtOnOmOuSdAtAbAsEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAutonomousDatabaseIDInsensitively(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.AutonomousDatabaseName != v.Expected.AutonomousDatabaseName { + t.Fatalf("Expected %q but got %q for AutonomousDatabaseName", v.Expected.AutonomousDatabaseName, actual.AutonomousDatabaseName) + } + + } +} + +func TestSegmentsForAutonomousDatabaseId(t *testing.T) { + segments := AutonomousDatabaseId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AutonomousDatabaseId 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/oracledatabase/2024-06-01/autonomousdatabasebackups/id_autonomousdatabasebackup.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/id_autonomousdatabasebackup.go new file mode 100644 index 00000000000..57cf278d0d7 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/id_autonomousdatabasebackup.go @@ -0,0 +1,139 @@ +package autonomousdatabasebackups + +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(&AutonomousDatabaseBackupId{}) +} + +var _ resourceids.ResourceId = &AutonomousDatabaseBackupId{} + +// AutonomousDatabaseBackupId is a struct representing the Resource ID for a Autonomous Database Backup +type AutonomousDatabaseBackupId struct { + SubscriptionId string + ResourceGroupName string + AutonomousDatabaseName string + AutonomousDatabaseBackupName string +} + +// NewAutonomousDatabaseBackupID returns a new AutonomousDatabaseBackupId struct +func NewAutonomousDatabaseBackupID(subscriptionId string, resourceGroupName string, autonomousDatabaseName string, autonomousDatabaseBackupName string) AutonomousDatabaseBackupId { + return AutonomousDatabaseBackupId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + AutonomousDatabaseName: autonomousDatabaseName, + AutonomousDatabaseBackupName: autonomousDatabaseBackupName, + } +} + +// ParseAutonomousDatabaseBackupID parses 'input' into a AutonomousDatabaseBackupId +func ParseAutonomousDatabaseBackupID(input string) (*AutonomousDatabaseBackupId, error) { + parser := resourceids.NewParserFromResourceIdType(&AutonomousDatabaseBackupId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AutonomousDatabaseBackupId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAutonomousDatabaseBackupIDInsensitively parses 'input' case-insensitively into a AutonomousDatabaseBackupId +// note: this method should only be used for API response data and not user input +func ParseAutonomousDatabaseBackupIDInsensitively(input string) (*AutonomousDatabaseBackupId, error) { + parser := resourceids.NewParserFromResourceIdType(&AutonomousDatabaseBackupId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AutonomousDatabaseBackupId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AutonomousDatabaseBackupId) 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.AutonomousDatabaseName, ok = input.Parsed["autonomousDatabaseName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "autonomousDatabaseName", input) + } + + if id.AutonomousDatabaseBackupName, ok = input.Parsed["autonomousDatabaseBackupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "autonomousDatabaseBackupName", input) + } + + return nil +} + +// ValidateAutonomousDatabaseBackupID checks that 'input' can be parsed as a Autonomous Database Backup ID +func ValidateAutonomousDatabaseBackupID(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 := ParseAutonomousDatabaseBackupID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Autonomous Database Backup ID +func (id AutonomousDatabaseBackupId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Oracle.Database/autonomousDatabases/%s/autonomousDatabaseBackups/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.AutonomousDatabaseName, id.AutonomousDatabaseBackupName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Autonomous Database Backup ID +func (id AutonomousDatabaseBackupId) 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("staticOracleDatabase", "Oracle.Database", "Oracle.Database"), + resourceids.StaticSegment("staticAutonomousDatabases", "autonomousDatabases", "autonomousDatabases"), + resourceids.UserSpecifiedSegment("autonomousDatabaseName", "autonomousDatabaseValue"), + resourceids.StaticSegment("staticAutonomousDatabaseBackups", "autonomousDatabaseBackups", "autonomousDatabaseBackups"), + resourceids.UserSpecifiedSegment("autonomousDatabaseBackupName", "autonomousDatabaseBackupValue"), + } +} + +// String returns a human-readable description of this Autonomous Database Backup ID +func (id AutonomousDatabaseBackupId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Autonomous Database Name: %q", id.AutonomousDatabaseName), + fmt.Sprintf("Autonomous Database Backup Name: %q", id.AutonomousDatabaseBackupName), + } + return fmt.Sprintf("Autonomous Database Backup (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/id_autonomousdatabasebackup_test.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/id_autonomousdatabasebackup_test.go new file mode 100644 index 00000000000..28b4af5b151 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/id_autonomousdatabasebackup_test.go @@ -0,0 +1,327 @@ +package autonomousdatabasebackups + +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 = &AutonomousDatabaseBackupId{} + +func TestNewAutonomousDatabaseBackupID(t *testing.T) { + id := NewAutonomousDatabaseBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "autonomousDatabaseValue", "autonomousDatabaseBackupValue") + + 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.AutonomousDatabaseName != "autonomousDatabaseValue" { + t.Fatalf("Expected %q but got %q for Segment 'AutonomousDatabaseName'", id.AutonomousDatabaseName, "autonomousDatabaseValue") + } + + if id.AutonomousDatabaseBackupName != "autonomousDatabaseBackupValue" { + t.Fatalf("Expected %q but got %q for Segment 'AutonomousDatabaseBackupName'", id.AutonomousDatabaseBackupName, "autonomousDatabaseBackupValue") + } +} + +func TestFormatAutonomousDatabaseBackupID(t *testing.T) { + actual := NewAutonomousDatabaseBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "autonomousDatabaseValue", "autonomousDatabaseBackupValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/autonomousDatabases/autonomousDatabaseValue/autonomousDatabaseBackups/autonomousDatabaseBackupValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAutonomousDatabaseBackupID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AutonomousDatabaseBackupId + }{ + { + // 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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/autonomousDatabases", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/autonomousDatabases/autonomousDatabaseValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/autonomousDatabases/autonomousDatabaseValue/autonomousDatabaseBackups", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/autonomousDatabases/autonomousDatabaseValue/autonomousDatabaseBackups/autonomousDatabaseBackupValue", + Expected: &AutonomousDatabaseBackupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + AutonomousDatabaseName: "autonomousDatabaseValue", + AutonomousDatabaseBackupName: "autonomousDatabaseBackupValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/autonomousDatabases/autonomousDatabaseValue/autonomousDatabaseBackups/autonomousDatabaseBackupValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAutonomousDatabaseBackupID(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.AutonomousDatabaseName != v.Expected.AutonomousDatabaseName { + t.Fatalf("Expected %q but got %q for AutonomousDatabaseName", v.Expected.AutonomousDatabaseName, actual.AutonomousDatabaseName) + } + + if actual.AutonomousDatabaseBackupName != v.Expected.AutonomousDatabaseBackupName { + t.Fatalf("Expected %q but got %q for AutonomousDatabaseBackupName", v.Expected.AutonomousDatabaseBackupName, actual.AutonomousDatabaseBackupName) + } + + } +} + +func TestParseAutonomousDatabaseBackupIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AutonomousDatabaseBackupId + }{ + { + // 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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/autonomousDatabases", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe/aUtOnOmOuSdAtAbAsEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/autonomousDatabases/autonomousDatabaseValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe/aUtOnOmOuSdAtAbAsEs/aUtOnOmOuSdAtAbAsEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/autonomousDatabases/autonomousDatabaseValue/autonomousDatabaseBackups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe/aUtOnOmOuSdAtAbAsEs/aUtOnOmOuSdAtAbAsEvAlUe/aUtOnOmOuSdAtAbAsEbAcKuPs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/autonomousDatabases/autonomousDatabaseValue/autonomousDatabaseBackups/autonomousDatabaseBackupValue", + Expected: &AutonomousDatabaseBackupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + AutonomousDatabaseName: "autonomousDatabaseValue", + AutonomousDatabaseBackupName: "autonomousDatabaseBackupValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/autonomousDatabases/autonomousDatabaseValue/autonomousDatabaseBackups/autonomousDatabaseBackupValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe/aUtOnOmOuSdAtAbAsEs/aUtOnOmOuSdAtAbAsEvAlUe/aUtOnOmOuSdAtAbAsEbAcKuPs/aUtOnOmOuSdAtAbAsEbAcKuPvAlUe", + Expected: &AutonomousDatabaseBackupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + AutonomousDatabaseName: "aUtOnOmOuSdAtAbAsEvAlUe", + AutonomousDatabaseBackupName: "aUtOnOmOuSdAtAbAsEbAcKuPvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe/aUtOnOmOuSdAtAbAsEs/aUtOnOmOuSdAtAbAsEvAlUe/aUtOnOmOuSdAtAbAsEbAcKuPs/aUtOnOmOuSdAtAbAsEbAcKuPvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAutonomousDatabaseBackupIDInsensitively(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.AutonomousDatabaseName != v.Expected.AutonomousDatabaseName { + t.Fatalf("Expected %q but got %q for AutonomousDatabaseName", v.Expected.AutonomousDatabaseName, actual.AutonomousDatabaseName) + } + + if actual.AutonomousDatabaseBackupName != v.Expected.AutonomousDatabaseBackupName { + t.Fatalf("Expected %q but got %q for AutonomousDatabaseBackupName", v.Expected.AutonomousDatabaseBackupName, actual.AutonomousDatabaseBackupName) + } + + } +} + +func TestSegmentsForAutonomousDatabaseBackupId(t *testing.T) { + segments := AutonomousDatabaseBackupId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AutonomousDatabaseBackupId 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/oracledatabase/2024-06-01/autonomousdatabasebackups/method_createorupdate.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/method_createorupdate.go new file mode 100644 index 00000000000..81b5ea2dbce --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/method_createorupdate.go @@ -0,0 +1,75 @@ +package autonomousdatabasebackups + +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 *AutonomousDatabaseBackup +} + +// CreateOrUpdate ... +func (c AutonomousDatabaseBackupsClient) CreateOrUpdate(ctx context.Context, id AutonomousDatabaseBackupId, input AutonomousDatabaseBackup) (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 AutonomousDatabaseBackupsClient) CreateOrUpdateThenPoll(ctx context.Context, id AutonomousDatabaseBackupId, input AutonomousDatabaseBackup) 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/oracledatabase/2024-06-01/autonomousdatabasebackups/method_delete.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/method_delete.go new file mode 100644 index 00000000000..4af10c5bf28 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/method_delete.go @@ -0,0 +1,70 @@ +package autonomousdatabasebackups + +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 AutonomousDatabaseBackupsClient) Delete(ctx context.Context, id AutonomousDatabaseBackupId) (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 AutonomousDatabaseBackupsClient) DeleteThenPoll(ctx context.Context, id AutonomousDatabaseBackupId) 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/oracledatabase/2024-06-01/autonomousdatabasebackups/method_get.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/method_get.go new file mode 100644 index 00000000000..ea57ba70411 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/method_get.go @@ -0,0 +1,54 @@ +package autonomousdatabasebackups + +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 *AutonomousDatabaseBackup +} + +// Get ... +func (c AutonomousDatabaseBackupsClient) Get(ctx context.Context, id AutonomousDatabaseBackupId) (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 AutonomousDatabaseBackup + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/method_listbyautonomousdatabase.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/method_listbyautonomousdatabase.go new file mode 100644 index 00000000000..38df32dfe02 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/method_listbyautonomousdatabase.go @@ -0,0 +1,105 @@ +package autonomousdatabasebackups + +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 ListByAutonomousDatabaseOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AutonomousDatabaseBackup +} + +type ListByAutonomousDatabaseCompleteResult struct { + LatestHttpResponse *http.Response + Items []AutonomousDatabaseBackup +} + +type ListByAutonomousDatabaseCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByAutonomousDatabaseCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByAutonomousDatabase ... +func (c AutonomousDatabaseBackupsClient) ListByAutonomousDatabase(ctx context.Context, id AutonomousDatabaseId) (result ListByAutonomousDatabaseOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByAutonomousDatabaseCustomPager{}, + Path: fmt.Sprintf("%s/autonomousDatabaseBackups", 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 *[]AutonomousDatabaseBackup `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByAutonomousDatabaseComplete retrieves all the results into a single object +func (c AutonomousDatabaseBackupsClient) ListByAutonomousDatabaseComplete(ctx context.Context, id AutonomousDatabaseId) (ListByAutonomousDatabaseCompleteResult, error) { + return c.ListByAutonomousDatabaseCompleteMatchingPredicate(ctx, id, AutonomousDatabaseBackupOperationPredicate{}) +} + +// ListByAutonomousDatabaseCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AutonomousDatabaseBackupsClient) ListByAutonomousDatabaseCompleteMatchingPredicate(ctx context.Context, id AutonomousDatabaseId, predicate AutonomousDatabaseBackupOperationPredicate) (result ListByAutonomousDatabaseCompleteResult, err error) { + items := make([]AutonomousDatabaseBackup, 0) + + resp, err := c.ListByAutonomousDatabase(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByAutonomousDatabaseCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/method_update.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/method_update.go new file mode 100644 index 00000000000..e769ca8bab9 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/method_update.go @@ -0,0 +1,75 @@ +package autonomousdatabasebackups + +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 *AutonomousDatabaseBackup +} + +// Update ... +func (c AutonomousDatabaseBackupsClient) Update(ctx context.Context, id AutonomousDatabaseBackupId, input AutonomousDatabaseBackupUpdate) (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 AutonomousDatabaseBackupsClient) UpdateThenPoll(ctx context.Context, id AutonomousDatabaseBackupId, input AutonomousDatabaseBackupUpdate) 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/oracledatabase/2024-06-01/autonomousdatabasebackups/model_autonomousdatabasebackup.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/model_autonomousdatabasebackup.go new file mode 100644 index 00000000000..d58ba310e22 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/model_autonomousdatabasebackup.go @@ -0,0 +1,16 @@ +package autonomousdatabasebackups + +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 AutonomousDatabaseBackup struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AutonomousDatabaseBackupProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/model_autonomousdatabasebackupproperties.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/model_autonomousdatabasebackupproperties.go new file mode 100644 index 00000000000..bb592faa99a --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/model_autonomousdatabasebackupproperties.go @@ -0,0 +1,41 @@ +package autonomousdatabasebackups + +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 AutonomousDatabaseBackupProperties struct { + AutonomousDatabaseOcid *string `json:"autonomousDatabaseOcid,omitempty"` + BackupType *AutonomousDatabaseBackupType `json:"backupType,omitempty"` + DatabaseSizeInTbs *float64 `json:"databaseSizeInTbs,omitempty"` + DbVersion *string `json:"dbVersion,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + IsAutomatic *bool `json:"isAutomatic,omitempty"` + IsRestorable *bool `json:"isRestorable,omitempty"` + LifecycleDetails *string `json:"lifecycleDetails,omitempty"` + LifecycleState *AutonomousDatabaseBackupLifecycleState `json:"lifecycleState,omitempty"` + Ocid *string `json:"ocid,omitempty"` + ProvisioningState *AzureResourceProvisioningState `json:"provisioningState,omitempty"` + RetentionPeriodInDays *int64 `json:"retentionPeriodInDays,omitempty"` + SizeInTbs *float64 `json:"sizeInTbs,omitempty"` + TimeAvailableTil *string `json:"timeAvailableTil,omitempty"` + TimeEnded *string `json:"timeEnded,omitempty"` + TimeStarted *string `json:"timeStarted,omitempty"` +} + +func (o *AutonomousDatabaseBackupProperties) GetTimeAvailableTilAsTime() (*time.Time, error) { + if o.TimeAvailableTil == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeAvailableTil, "2006-01-02T15:04:05Z07:00") +} + +func (o *AutonomousDatabaseBackupProperties) SetTimeAvailableTilAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeAvailableTil = &formatted +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/model_autonomousdatabasebackupupdate.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/model_autonomousdatabasebackupupdate.go new file mode 100644 index 00000000000..4ccab72b0dc --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/model_autonomousdatabasebackupupdate.go @@ -0,0 +1,8 @@ +package autonomousdatabasebackups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutonomousDatabaseBackupUpdate struct { + Properties *AutonomousDatabaseBackupUpdateProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/model_autonomousdatabasebackupupdateproperties.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/model_autonomousdatabasebackupupdateproperties.go new file mode 100644 index 00000000000..cebcbe7eb15 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/model_autonomousdatabasebackupupdateproperties.go @@ -0,0 +1,8 @@ +package autonomousdatabasebackups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutonomousDatabaseBackupUpdateProperties struct { + RetentionPeriodInDays *int64 `json:"retentionPeriodInDays,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/predicates.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/predicates.go new file mode 100644 index 00000000000..ba62aa1ff05 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/predicates.go @@ -0,0 +1,27 @@ +package autonomousdatabasebackups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutonomousDatabaseBackupOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p AutonomousDatabaseBackupOperationPredicate) Matches(input AutonomousDatabaseBackup) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/version.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/version.go new file mode 100644 index 00000000000..3c5e45d7b47 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasebackups/version.go @@ -0,0 +1,12 @@ +package autonomousdatabasebackups + +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-06-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/autonomousdatabasebackups/%s", defaultApiVersion) +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/README.md b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/README.md new file mode 100644 index 00000000000..ad086f941b1 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets` Documentation + +The `autonomousdatabasecharactersets` SDK allows for interaction with the Azure Resource Manager Service `oracledatabase` (API Version `2024-06-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/oracledatabase/2024-06-01/autonomousdatabasecharactersets" +``` + + +### Client Initialization + +```go +client := autonomousdatabasecharactersets.NewAutonomousDatabaseCharacterSetsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AutonomousDatabaseCharacterSetsClient.Get` + +```go +ctx := context.TODO() +id := autonomousdatabasecharactersets.NewAutonomousDatabaseCharacterSetID("12345678-1234-9876-4563-123456789012", "locationValue", "autonomousDatabaseCharacterSetValue") + +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: `AutonomousDatabaseCharacterSetsClient.ListByLocation` + +```go +ctx := context.TODO() +id := autonomousdatabasecharactersets.NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + +// alternatively `client.ListByLocation(ctx, id)` can be used to do batched pagination +items, err := client.ListByLocationComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/client.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/client.go new file mode 100644 index 00000000000..ef4620ad838 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/client.go @@ -0,0 +1,26 @@ +package autonomousdatabasecharactersets + +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 AutonomousDatabaseCharacterSetsClient struct { + Client *resourcemanager.Client +} + +func NewAutonomousDatabaseCharacterSetsClientWithBaseURI(sdkApi sdkEnv.Api) (*AutonomousDatabaseCharacterSetsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "autonomousdatabasecharactersets", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AutonomousDatabaseCharacterSetsClient: %+v", err) + } + + return &AutonomousDatabaseCharacterSetsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/id_autonomousdatabasecharacterset.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/id_autonomousdatabasecharacterset.go new file mode 100644 index 00000000000..b9ac00fb4fe --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/id_autonomousdatabasecharacterset.go @@ -0,0 +1,130 @@ +package autonomousdatabasecharactersets + +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(&AutonomousDatabaseCharacterSetId{}) +} + +var _ resourceids.ResourceId = &AutonomousDatabaseCharacterSetId{} + +// AutonomousDatabaseCharacterSetId is a struct representing the Resource ID for a Autonomous Database Character Set +type AutonomousDatabaseCharacterSetId struct { + SubscriptionId string + LocationName string + AutonomousDatabaseCharacterSetName string +} + +// NewAutonomousDatabaseCharacterSetID returns a new AutonomousDatabaseCharacterSetId struct +func NewAutonomousDatabaseCharacterSetID(subscriptionId string, locationName string, autonomousDatabaseCharacterSetName string) AutonomousDatabaseCharacterSetId { + return AutonomousDatabaseCharacterSetId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + AutonomousDatabaseCharacterSetName: autonomousDatabaseCharacterSetName, + } +} + +// ParseAutonomousDatabaseCharacterSetID parses 'input' into a AutonomousDatabaseCharacterSetId +func ParseAutonomousDatabaseCharacterSetID(input string) (*AutonomousDatabaseCharacterSetId, error) { + parser := resourceids.NewParserFromResourceIdType(&AutonomousDatabaseCharacterSetId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AutonomousDatabaseCharacterSetId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAutonomousDatabaseCharacterSetIDInsensitively parses 'input' case-insensitively into a AutonomousDatabaseCharacterSetId +// note: this method should only be used for API response data and not user input +func ParseAutonomousDatabaseCharacterSetIDInsensitively(input string) (*AutonomousDatabaseCharacterSetId, error) { + parser := resourceids.NewParserFromResourceIdType(&AutonomousDatabaseCharacterSetId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AutonomousDatabaseCharacterSetId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AutonomousDatabaseCharacterSetId) 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) + } + + if id.AutonomousDatabaseCharacterSetName, ok = input.Parsed["autonomousDatabaseCharacterSetName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "autonomousDatabaseCharacterSetName", input) + } + + return nil +} + +// ValidateAutonomousDatabaseCharacterSetID checks that 'input' can be parsed as a Autonomous Database Character Set ID +func ValidateAutonomousDatabaseCharacterSetID(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 := ParseAutonomousDatabaseCharacterSetID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Autonomous Database Character Set ID +func (id AutonomousDatabaseCharacterSetId) ID() string { + fmtString := "/subscriptions/%s/providers/Oracle.Database/locations/%s/autonomousDatabaseCharacterSets/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName, id.AutonomousDatabaseCharacterSetName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Autonomous Database Character Set ID +func (id AutonomousDatabaseCharacterSetId) 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("staticOracleDatabase", "Oracle.Database", "Oracle.Database"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationValue"), + resourceids.StaticSegment("staticAutonomousDatabaseCharacterSets", "autonomousDatabaseCharacterSets", "autonomousDatabaseCharacterSets"), + resourceids.UserSpecifiedSegment("autonomousDatabaseCharacterSetName", "autonomousDatabaseCharacterSetValue"), + } +} + +// String returns a human-readable description of this Autonomous Database Character Set ID +func (id AutonomousDatabaseCharacterSetId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + fmt.Sprintf("Autonomous Database Character Set Name: %q", id.AutonomousDatabaseCharacterSetName), + } + return fmt.Sprintf("Autonomous Database Character Set (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/id_autonomousdatabasecharacterset_test.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/id_autonomousdatabasecharacterset_test.go new file mode 100644 index 00000000000..42f7f18af5a --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/id_autonomousdatabasecharacterset_test.go @@ -0,0 +1,282 @@ +package autonomousdatabasecharactersets + +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 = &AutonomousDatabaseCharacterSetId{} + +func TestNewAutonomousDatabaseCharacterSetID(t *testing.T) { + id := NewAutonomousDatabaseCharacterSetID("12345678-1234-9876-4563-123456789012", "locationValue", "autonomousDatabaseCharacterSetValue") + + 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") + } + + if id.AutonomousDatabaseCharacterSetName != "autonomousDatabaseCharacterSetValue" { + t.Fatalf("Expected %q but got %q for Segment 'AutonomousDatabaseCharacterSetName'", id.AutonomousDatabaseCharacterSetName, "autonomousDatabaseCharacterSetValue") + } +} + +func TestFormatAutonomousDatabaseCharacterSetID(t *testing.T) { + actual := NewAutonomousDatabaseCharacterSetID("12345678-1234-9876-4563-123456789012", "locationValue", "autonomousDatabaseCharacterSetValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/autonomousDatabaseCharacterSets/autonomousDatabaseCharacterSetValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAutonomousDatabaseCharacterSetID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AutonomousDatabaseCharacterSetId + }{ + { + // 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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/autonomousDatabaseCharacterSets", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/autonomousDatabaseCharacterSets/autonomousDatabaseCharacterSetValue", + Expected: &AutonomousDatabaseCharacterSetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + AutonomousDatabaseCharacterSetName: "autonomousDatabaseCharacterSetValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/autonomousDatabaseCharacterSets/autonomousDatabaseCharacterSetValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAutonomousDatabaseCharacterSetID(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) + } + + if actual.AutonomousDatabaseCharacterSetName != v.Expected.AutonomousDatabaseCharacterSetName { + t.Fatalf("Expected %q but got %q for AutonomousDatabaseCharacterSetName", v.Expected.AutonomousDatabaseCharacterSetName, actual.AutonomousDatabaseCharacterSetName) + } + + } +} + +func TestParseAutonomousDatabaseCharacterSetIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AutonomousDatabaseCharacterSetId + }{ + { + // 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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs/lOcAtIoNvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/autonomousDatabaseCharacterSets", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs/lOcAtIoNvAlUe/aUtOnOmOuSdAtAbAsEcHaRaCtErSeTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/autonomousDatabaseCharacterSets/autonomousDatabaseCharacterSetValue", + Expected: &AutonomousDatabaseCharacterSetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + AutonomousDatabaseCharacterSetName: "autonomousDatabaseCharacterSetValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/autonomousDatabaseCharacterSets/autonomousDatabaseCharacterSetValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs/lOcAtIoNvAlUe/aUtOnOmOuSdAtAbAsEcHaRaCtErSeTs/aUtOnOmOuSdAtAbAsEcHaRaCtErSeTvAlUe", + Expected: &AutonomousDatabaseCharacterSetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNvAlUe", + AutonomousDatabaseCharacterSetName: "aUtOnOmOuSdAtAbAsEcHaRaCtErSeTvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs/lOcAtIoNvAlUe/aUtOnOmOuSdAtAbAsEcHaRaCtErSeTs/aUtOnOmOuSdAtAbAsEcHaRaCtErSeTvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAutonomousDatabaseCharacterSetIDInsensitively(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) + } + + if actual.AutonomousDatabaseCharacterSetName != v.Expected.AutonomousDatabaseCharacterSetName { + t.Fatalf("Expected %q but got %q for AutonomousDatabaseCharacterSetName", v.Expected.AutonomousDatabaseCharacterSetName, actual.AutonomousDatabaseCharacterSetName) + } + + } +} + +func TestSegmentsForAutonomousDatabaseCharacterSetId(t *testing.T) { + segments := AutonomousDatabaseCharacterSetId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AutonomousDatabaseCharacterSetId 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/oracledatabase/2024-06-01/autonomousdatabasecharactersets/id_location.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/id_location.go new file mode 100644 index 00000000000..54fb13304a4 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/id_location.go @@ -0,0 +1,121 @@ +package autonomousdatabasecharactersets + +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/Oracle.Database/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("staticOracleDatabase", "Oracle.Database", "Oracle.Database"), + 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/oracledatabase/2024-06-01/autonomousdatabasecharactersets/id_location_test.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/id_location_test.go new file mode 100644 index 00000000000..4f7f08e98dc --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/id_location_test.go @@ -0,0 +1,237 @@ +package autonomousdatabasecharactersets + +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/Oracle.Database/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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/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/Oracle.Database/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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/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/Oracle.Database/locations/locationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/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/oRaClE.DaTaBaSe/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/oracledatabase/2024-06-01/autonomousdatabasecharactersets/method_get.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/method_get.go new file mode 100644 index 00000000000..e372685113d --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/method_get.go @@ -0,0 +1,54 @@ +package autonomousdatabasecharactersets + +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 *AutonomousDatabaseCharacterSet +} + +// Get ... +func (c AutonomousDatabaseCharacterSetsClient) Get(ctx context.Context, id AutonomousDatabaseCharacterSetId) (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 AutonomousDatabaseCharacterSet + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/method_listbylocation.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/method_listbylocation.go new file mode 100644 index 00000000000..fed9644ac13 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/method_listbylocation.go @@ -0,0 +1,105 @@ +package autonomousdatabasecharactersets + +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 ListByLocationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AutonomousDatabaseCharacterSet +} + +type ListByLocationCompleteResult struct { + LatestHttpResponse *http.Response + Items []AutonomousDatabaseCharacterSet +} + +type ListByLocationCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByLocationCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByLocation ... +func (c AutonomousDatabaseCharacterSetsClient) ListByLocation(ctx context.Context, id LocationId) (result ListByLocationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByLocationCustomPager{}, + Path: fmt.Sprintf("%s/autonomousDatabaseCharacterSets", 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 *[]AutonomousDatabaseCharacterSet `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByLocationComplete retrieves all the results into a single object +func (c AutonomousDatabaseCharacterSetsClient) ListByLocationComplete(ctx context.Context, id LocationId) (ListByLocationCompleteResult, error) { + return c.ListByLocationCompleteMatchingPredicate(ctx, id, AutonomousDatabaseCharacterSetOperationPredicate{}) +} + +// ListByLocationCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AutonomousDatabaseCharacterSetsClient) ListByLocationCompleteMatchingPredicate(ctx context.Context, id LocationId, predicate AutonomousDatabaseCharacterSetOperationPredicate) (result ListByLocationCompleteResult, err error) { + items := make([]AutonomousDatabaseCharacterSet, 0) + + resp, err := c.ListByLocation(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByLocationCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/model_autonomousdatabasecharacterset.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/model_autonomousdatabasecharacterset.go new file mode 100644 index 00000000000..6fa0b10b403 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/model_autonomousdatabasecharacterset.go @@ -0,0 +1,16 @@ +package autonomousdatabasecharactersets + +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 AutonomousDatabaseCharacterSet struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AutonomousDatabaseCharacterSetProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/model_autonomousdatabasecharactersetproperties.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/model_autonomousdatabasecharactersetproperties.go new file mode 100644 index 00000000000..901e37d3b14 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/model_autonomousdatabasecharactersetproperties.go @@ -0,0 +1,8 @@ +package autonomousdatabasecharactersets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutonomousDatabaseCharacterSetProperties struct { + CharacterSet *string `json:"characterSet,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/predicates.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/predicates.go new file mode 100644 index 00000000000..248c5399d40 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/predicates.go @@ -0,0 +1,27 @@ +package autonomousdatabasecharactersets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutonomousDatabaseCharacterSetOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p AutonomousDatabaseCharacterSetOperationPredicate) Matches(input AutonomousDatabaseCharacterSet) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/version.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/version.go new file mode 100644 index 00000000000..308cf174055 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets/version.go @@ -0,0 +1,12 @@ +package autonomousdatabasecharactersets + +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-06-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/autonomousdatabasecharactersets/%s", defaultApiVersion) +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/README.md b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/README.md new file mode 100644 index 00000000000..eb59131ad18 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets` Documentation + +The `autonomousdatabasenationalcharactersets` SDK allows for interaction with the Azure Resource Manager Service `oracledatabase` (API Version `2024-06-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/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets" +``` + + +### Client Initialization + +```go +client := autonomousdatabasenationalcharactersets.NewAutonomousDatabaseNationalCharacterSetsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AutonomousDatabaseNationalCharacterSetsClient.Get` + +```go +ctx := context.TODO() +id := autonomousdatabasenationalcharactersets.NewAutonomousDatabaseNationalCharacterSetID("12345678-1234-9876-4563-123456789012", "locationValue", "autonomousDatabaseNationalCharacterSetValue") + +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: `AutonomousDatabaseNationalCharacterSetsClient.ListByLocation` + +```go +ctx := context.TODO() +id := autonomousdatabasenationalcharactersets.NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + +// alternatively `client.ListByLocation(ctx, id)` can be used to do batched pagination +items, err := client.ListByLocationComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/client.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/client.go new file mode 100644 index 00000000000..0d61e0105a1 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/client.go @@ -0,0 +1,26 @@ +package autonomousdatabasenationalcharactersets + +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 AutonomousDatabaseNationalCharacterSetsClient struct { + Client *resourcemanager.Client +} + +func NewAutonomousDatabaseNationalCharacterSetsClientWithBaseURI(sdkApi sdkEnv.Api) (*AutonomousDatabaseNationalCharacterSetsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "autonomousdatabasenationalcharactersets", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AutonomousDatabaseNationalCharacterSetsClient: %+v", err) + } + + return &AutonomousDatabaseNationalCharacterSetsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/id_autonomousdatabasenationalcharacterset.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/id_autonomousdatabasenationalcharacterset.go new file mode 100644 index 00000000000..62990b24a8a --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/id_autonomousdatabasenationalcharacterset.go @@ -0,0 +1,130 @@ +package autonomousdatabasenationalcharactersets + +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(&AutonomousDatabaseNationalCharacterSetId{}) +} + +var _ resourceids.ResourceId = &AutonomousDatabaseNationalCharacterSetId{} + +// AutonomousDatabaseNationalCharacterSetId is a struct representing the Resource ID for a Autonomous Database National Character Set +type AutonomousDatabaseNationalCharacterSetId struct { + SubscriptionId string + LocationName string + AutonomousDatabaseNationalCharacterSetName string +} + +// NewAutonomousDatabaseNationalCharacterSetID returns a new AutonomousDatabaseNationalCharacterSetId struct +func NewAutonomousDatabaseNationalCharacterSetID(subscriptionId string, locationName string, autonomousDatabaseNationalCharacterSetName string) AutonomousDatabaseNationalCharacterSetId { + return AutonomousDatabaseNationalCharacterSetId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + AutonomousDatabaseNationalCharacterSetName: autonomousDatabaseNationalCharacterSetName, + } +} + +// ParseAutonomousDatabaseNationalCharacterSetID parses 'input' into a AutonomousDatabaseNationalCharacterSetId +func ParseAutonomousDatabaseNationalCharacterSetID(input string) (*AutonomousDatabaseNationalCharacterSetId, error) { + parser := resourceids.NewParserFromResourceIdType(&AutonomousDatabaseNationalCharacterSetId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AutonomousDatabaseNationalCharacterSetId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAutonomousDatabaseNationalCharacterSetIDInsensitively parses 'input' case-insensitively into a AutonomousDatabaseNationalCharacterSetId +// note: this method should only be used for API response data and not user input +func ParseAutonomousDatabaseNationalCharacterSetIDInsensitively(input string) (*AutonomousDatabaseNationalCharacterSetId, error) { + parser := resourceids.NewParserFromResourceIdType(&AutonomousDatabaseNationalCharacterSetId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AutonomousDatabaseNationalCharacterSetId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AutonomousDatabaseNationalCharacterSetId) 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) + } + + if id.AutonomousDatabaseNationalCharacterSetName, ok = input.Parsed["autonomousDatabaseNationalCharacterSetName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "autonomousDatabaseNationalCharacterSetName", input) + } + + return nil +} + +// ValidateAutonomousDatabaseNationalCharacterSetID checks that 'input' can be parsed as a Autonomous Database National Character Set ID +func ValidateAutonomousDatabaseNationalCharacterSetID(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 := ParseAutonomousDatabaseNationalCharacterSetID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Autonomous Database National Character Set ID +func (id AutonomousDatabaseNationalCharacterSetId) ID() string { + fmtString := "/subscriptions/%s/providers/Oracle.Database/locations/%s/autonomousDatabaseNationalCharacterSets/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName, id.AutonomousDatabaseNationalCharacterSetName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Autonomous Database National Character Set ID +func (id AutonomousDatabaseNationalCharacterSetId) 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("staticOracleDatabase", "Oracle.Database", "Oracle.Database"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationValue"), + resourceids.StaticSegment("staticAutonomousDatabaseNationalCharacterSets", "autonomousDatabaseNationalCharacterSets", "autonomousDatabaseNationalCharacterSets"), + resourceids.UserSpecifiedSegment("autonomousDatabaseNationalCharacterSetName", "autonomousDatabaseNationalCharacterSetValue"), + } +} + +// String returns a human-readable description of this Autonomous Database National Character Set ID +func (id AutonomousDatabaseNationalCharacterSetId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + fmt.Sprintf("Autonomous Database National Character Set Name: %q", id.AutonomousDatabaseNationalCharacterSetName), + } + return fmt.Sprintf("Autonomous Database National Character Set (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/id_autonomousdatabasenationalcharacterset_test.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/id_autonomousdatabasenationalcharacterset_test.go new file mode 100644 index 00000000000..44505a3f457 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/id_autonomousdatabasenationalcharacterset_test.go @@ -0,0 +1,282 @@ +package autonomousdatabasenationalcharactersets + +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 = &AutonomousDatabaseNationalCharacterSetId{} + +func TestNewAutonomousDatabaseNationalCharacterSetID(t *testing.T) { + id := NewAutonomousDatabaseNationalCharacterSetID("12345678-1234-9876-4563-123456789012", "locationValue", "autonomousDatabaseNationalCharacterSetValue") + + 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") + } + + if id.AutonomousDatabaseNationalCharacterSetName != "autonomousDatabaseNationalCharacterSetValue" { + t.Fatalf("Expected %q but got %q for Segment 'AutonomousDatabaseNationalCharacterSetName'", id.AutonomousDatabaseNationalCharacterSetName, "autonomousDatabaseNationalCharacterSetValue") + } +} + +func TestFormatAutonomousDatabaseNationalCharacterSetID(t *testing.T) { + actual := NewAutonomousDatabaseNationalCharacterSetID("12345678-1234-9876-4563-123456789012", "locationValue", "autonomousDatabaseNationalCharacterSetValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/autonomousDatabaseNationalCharacterSets/autonomousDatabaseNationalCharacterSetValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAutonomousDatabaseNationalCharacterSetID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AutonomousDatabaseNationalCharacterSetId + }{ + { + // 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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/autonomousDatabaseNationalCharacterSets", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/autonomousDatabaseNationalCharacterSets/autonomousDatabaseNationalCharacterSetValue", + Expected: &AutonomousDatabaseNationalCharacterSetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + AutonomousDatabaseNationalCharacterSetName: "autonomousDatabaseNationalCharacterSetValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/autonomousDatabaseNationalCharacterSets/autonomousDatabaseNationalCharacterSetValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAutonomousDatabaseNationalCharacterSetID(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) + } + + if actual.AutonomousDatabaseNationalCharacterSetName != v.Expected.AutonomousDatabaseNationalCharacterSetName { + t.Fatalf("Expected %q but got %q for AutonomousDatabaseNationalCharacterSetName", v.Expected.AutonomousDatabaseNationalCharacterSetName, actual.AutonomousDatabaseNationalCharacterSetName) + } + + } +} + +func TestParseAutonomousDatabaseNationalCharacterSetIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AutonomousDatabaseNationalCharacterSetId + }{ + { + // 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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs/lOcAtIoNvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/autonomousDatabaseNationalCharacterSets", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs/lOcAtIoNvAlUe/aUtOnOmOuSdAtAbAsEnAtIoNaLcHaRaCtErSeTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/autonomousDatabaseNationalCharacterSets/autonomousDatabaseNationalCharacterSetValue", + Expected: &AutonomousDatabaseNationalCharacterSetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + AutonomousDatabaseNationalCharacterSetName: "autonomousDatabaseNationalCharacterSetValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/autonomousDatabaseNationalCharacterSets/autonomousDatabaseNationalCharacterSetValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs/lOcAtIoNvAlUe/aUtOnOmOuSdAtAbAsEnAtIoNaLcHaRaCtErSeTs/aUtOnOmOuSdAtAbAsEnAtIoNaLcHaRaCtErSeTvAlUe", + Expected: &AutonomousDatabaseNationalCharacterSetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNvAlUe", + AutonomousDatabaseNationalCharacterSetName: "aUtOnOmOuSdAtAbAsEnAtIoNaLcHaRaCtErSeTvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs/lOcAtIoNvAlUe/aUtOnOmOuSdAtAbAsEnAtIoNaLcHaRaCtErSeTs/aUtOnOmOuSdAtAbAsEnAtIoNaLcHaRaCtErSeTvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAutonomousDatabaseNationalCharacterSetIDInsensitively(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) + } + + if actual.AutonomousDatabaseNationalCharacterSetName != v.Expected.AutonomousDatabaseNationalCharacterSetName { + t.Fatalf("Expected %q but got %q for AutonomousDatabaseNationalCharacterSetName", v.Expected.AutonomousDatabaseNationalCharacterSetName, actual.AutonomousDatabaseNationalCharacterSetName) + } + + } +} + +func TestSegmentsForAutonomousDatabaseNationalCharacterSetId(t *testing.T) { + segments := AutonomousDatabaseNationalCharacterSetId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AutonomousDatabaseNationalCharacterSetId 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/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/id_location.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/id_location.go new file mode 100644 index 00000000000..d4c5968ec0d --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/id_location.go @@ -0,0 +1,121 @@ +package autonomousdatabasenationalcharactersets + +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/Oracle.Database/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("staticOracleDatabase", "Oracle.Database", "Oracle.Database"), + 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/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/id_location_test.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/id_location_test.go new file mode 100644 index 00000000000..7c03efcbed1 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/id_location_test.go @@ -0,0 +1,237 @@ +package autonomousdatabasenationalcharactersets + +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/Oracle.Database/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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/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/Oracle.Database/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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/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/Oracle.Database/locations/locationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/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/oRaClE.DaTaBaSe/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/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/method_get.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/method_get.go new file mode 100644 index 00000000000..f4ec84c1380 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/method_get.go @@ -0,0 +1,54 @@ +package autonomousdatabasenationalcharactersets + +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 *AutonomousDatabaseNationalCharacterSet +} + +// Get ... +func (c AutonomousDatabaseNationalCharacterSetsClient) Get(ctx context.Context, id AutonomousDatabaseNationalCharacterSetId) (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 AutonomousDatabaseNationalCharacterSet + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/method_listbylocation.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/method_listbylocation.go new file mode 100644 index 00000000000..98ab6421827 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/method_listbylocation.go @@ -0,0 +1,105 @@ +package autonomousdatabasenationalcharactersets + +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 ListByLocationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AutonomousDatabaseNationalCharacterSet +} + +type ListByLocationCompleteResult struct { + LatestHttpResponse *http.Response + Items []AutonomousDatabaseNationalCharacterSet +} + +type ListByLocationCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByLocationCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByLocation ... +func (c AutonomousDatabaseNationalCharacterSetsClient) ListByLocation(ctx context.Context, id LocationId) (result ListByLocationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByLocationCustomPager{}, + Path: fmt.Sprintf("%s/autonomousDatabaseNationalCharacterSets", 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 *[]AutonomousDatabaseNationalCharacterSet `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByLocationComplete retrieves all the results into a single object +func (c AutonomousDatabaseNationalCharacterSetsClient) ListByLocationComplete(ctx context.Context, id LocationId) (ListByLocationCompleteResult, error) { + return c.ListByLocationCompleteMatchingPredicate(ctx, id, AutonomousDatabaseNationalCharacterSetOperationPredicate{}) +} + +// ListByLocationCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AutonomousDatabaseNationalCharacterSetsClient) ListByLocationCompleteMatchingPredicate(ctx context.Context, id LocationId, predicate AutonomousDatabaseNationalCharacterSetOperationPredicate) (result ListByLocationCompleteResult, err error) { + items := make([]AutonomousDatabaseNationalCharacterSet, 0) + + resp, err := c.ListByLocation(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByLocationCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/model_autonomousdatabasenationalcharacterset.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/model_autonomousdatabasenationalcharacterset.go new file mode 100644 index 00000000000..1bf4f8d2c11 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/model_autonomousdatabasenationalcharacterset.go @@ -0,0 +1,16 @@ +package autonomousdatabasenationalcharactersets + +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 AutonomousDatabaseNationalCharacterSet struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AutonomousDatabaseNationalCharacterSetProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/model_autonomousdatabasenationalcharactersetproperties.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/model_autonomousdatabasenationalcharactersetproperties.go new file mode 100644 index 00000000000..075fdf79954 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/model_autonomousdatabasenationalcharactersetproperties.go @@ -0,0 +1,8 @@ +package autonomousdatabasenationalcharactersets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutonomousDatabaseNationalCharacterSetProperties struct { + CharacterSet *string `json:"characterSet,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/predicates.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/predicates.go new file mode 100644 index 00000000000..6dcbbef5c7b --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/predicates.go @@ -0,0 +1,27 @@ +package autonomousdatabasenationalcharactersets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutonomousDatabaseNationalCharacterSetOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p AutonomousDatabaseNationalCharacterSetOperationPredicate) Matches(input AutonomousDatabaseNationalCharacterSet) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/version.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/version.go new file mode 100644 index 00000000000..1be761ae3ed --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets/version.go @@ -0,0 +1,12 @@ +package autonomousdatabasenationalcharactersets + +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-06-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/autonomousdatabasenationalcharactersets/%s", defaultApiVersion) +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/README.md b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/README.md new file mode 100644 index 00000000000..21610575ab1 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/README.md @@ -0,0 +1,201 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/autonomousdatabases` Documentation + +The `autonomousdatabases` SDK allows for interaction with the Azure Resource Manager Service `oracledatabase` (API Version `2024-06-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/oracledatabase/2024-06-01/autonomousdatabases" +``` + + +### Client Initialization + +```go +client := autonomousdatabases.NewAutonomousDatabasesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AutonomousDatabasesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := autonomousdatabases.NewAutonomousDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "autonomousDatabaseValue") + +payload := autonomousdatabases.AutonomousDatabase{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AutonomousDatabasesClient.Delete` + +```go +ctx := context.TODO() +id := autonomousdatabases.NewAutonomousDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "autonomousDatabaseValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `AutonomousDatabasesClient.Failover` + +```go +ctx := context.TODO() +id := autonomousdatabases.NewAutonomousDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "autonomousDatabaseValue") + +payload := autonomousdatabases.PeerDbDetails{ + // ... +} + + +if err := client.FailoverThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AutonomousDatabasesClient.GenerateWallet` + +```go +ctx := context.TODO() +id := autonomousdatabases.NewAutonomousDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "autonomousDatabaseValue") + +payload := autonomousdatabases.GenerateAutonomousDatabaseWalletDetails{ + // ... +} + + +read, err := client.GenerateWallet(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AutonomousDatabasesClient.Get` + +```go +ctx := context.TODO() +id := autonomousdatabases.NewAutonomousDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "autonomousDatabaseValue") + +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: `AutonomousDatabasesClient.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: `AutonomousDatabasesClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AutonomousDatabasesClient.Restore` + +```go +ctx := context.TODO() +id := autonomousdatabases.NewAutonomousDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "autonomousDatabaseValue") + +payload := autonomousdatabases.RestoreAutonomousDatabaseDetails{ + // ... +} + + +if err := client.RestoreThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AutonomousDatabasesClient.Shrink` + +```go +ctx := context.TODO() +id := autonomousdatabases.NewAutonomousDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "autonomousDatabaseValue") + +if err := client.ShrinkThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `AutonomousDatabasesClient.Switchover` + +```go +ctx := context.TODO() +id := autonomousdatabases.NewAutonomousDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "autonomousDatabaseValue") + +payload := autonomousdatabases.PeerDbDetails{ + // ... +} + + +if err := client.SwitchoverThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AutonomousDatabasesClient.Update` + +```go +ctx := context.TODO() +id := autonomousdatabases.NewAutonomousDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "autonomousDatabaseValue") + +payload := autonomousdatabases.AutonomousDatabaseUpdate{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/client.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/client.go new file mode 100644 index 00000000000..d9e2e2e1096 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/client.go @@ -0,0 +1,26 @@ +package autonomousdatabases + +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 AutonomousDatabasesClient struct { + Client *resourcemanager.Client +} + +func NewAutonomousDatabasesClientWithBaseURI(sdkApi sdkEnv.Api) (*AutonomousDatabasesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "autonomousdatabases", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AutonomousDatabasesClient: %+v", err) + } + + return &AutonomousDatabasesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/constants.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/constants.go new file mode 100644 index 00000000000..22b9ad59574 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/constants.go @@ -0,0 +1,1264 @@ +package autonomousdatabases + +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 AutonomousDatabaseLifecycleState string + +const ( + AutonomousDatabaseLifecycleStateAvailable AutonomousDatabaseLifecycleState = "Available" + AutonomousDatabaseLifecycleStateAvailableNeedsAttention AutonomousDatabaseLifecycleState = "AvailableNeedsAttention" + AutonomousDatabaseLifecycleStateBackupInProgress AutonomousDatabaseLifecycleState = "BackupInProgress" + AutonomousDatabaseLifecycleStateInaccessible AutonomousDatabaseLifecycleState = "Inaccessible" + AutonomousDatabaseLifecycleStateMaintenanceInProgress AutonomousDatabaseLifecycleState = "MaintenanceInProgress" + AutonomousDatabaseLifecycleStateProvisioning AutonomousDatabaseLifecycleState = "Provisioning" + AutonomousDatabaseLifecycleStateRecreating AutonomousDatabaseLifecycleState = "Recreating" + AutonomousDatabaseLifecycleStateRestarting AutonomousDatabaseLifecycleState = "Restarting" + AutonomousDatabaseLifecycleStateRestoreFailed AutonomousDatabaseLifecycleState = "RestoreFailed" + AutonomousDatabaseLifecycleStateRestoreInProgress AutonomousDatabaseLifecycleState = "RestoreInProgress" + AutonomousDatabaseLifecycleStateRoleChangeInProgress AutonomousDatabaseLifecycleState = "RoleChangeInProgress" + AutonomousDatabaseLifecycleStateScaleInProgress AutonomousDatabaseLifecycleState = "ScaleInProgress" + AutonomousDatabaseLifecycleStateStandby AutonomousDatabaseLifecycleState = "Standby" + AutonomousDatabaseLifecycleStateStarting AutonomousDatabaseLifecycleState = "Starting" + AutonomousDatabaseLifecycleStateStopped AutonomousDatabaseLifecycleState = "Stopped" + AutonomousDatabaseLifecycleStateStopping AutonomousDatabaseLifecycleState = "Stopping" + AutonomousDatabaseLifecycleStateTerminated AutonomousDatabaseLifecycleState = "Terminated" + AutonomousDatabaseLifecycleStateTerminating AutonomousDatabaseLifecycleState = "Terminating" + AutonomousDatabaseLifecycleStateUnavailable AutonomousDatabaseLifecycleState = "Unavailable" + AutonomousDatabaseLifecycleStateUpdating AutonomousDatabaseLifecycleState = "Updating" + AutonomousDatabaseLifecycleStateUpgrading AutonomousDatabaseLifecycleState = "Upgrading" +) + +func PossibleValuesForAutonomousDatabaseLifecycleState() []string { + return []string{ + string(AutonomousDatabaseLifecycleStateAvailable), + string(AutonomousDatabaseLifecycleStateAvailableNeedsAttention), + string(AutonomousDatabaseLifecycleStateBackupInProgress), + string(AutonomousDatabaseLifecycleStateInaccessible), + string(AutonomousDatabaseLifecycleStateMaintenanceInProgress), + string(AutonomousDatabaseLifecycleStateProvisioning), + string(AutonomousDatabaseLifecycleStateRecreating), + string(AutonomousDatabaseLifecycleStateRestarting), + string(AutonomousDatabaseLifecycleStateRestoreFailed), + string(AutonomousDatabaseLifecycleStateRestoreInProgress), + string(AutonomousDatabaseLifecycleStateRoleChangeInProgress), + string(AutonomousDatabaseLifecycleStateScaleInProgress), + string(AutonomousDatabaseLifecycleStateStandby), + string(AutonomousDatabaseLifecycleStateStarting), + string(AutonomousDatabaseLifecycleStateStopped), + string(AutonomousDatabaseLifecycleStateStopping), + string(AutonomousDatabaseLifecycleStateTerminated), + string(AutonomousDatabaseLifecycleStateTerminating), + string(AutonomousDatabaseLifecycleStateUnavailable), + string(AutonomousDatabaseLifecycleStateUpdating), + string(AutonomousDatabaseLifecycleStateUpgrading), + } +} + +func (s *AutonomousDatabaseLifecycleState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutonomousDatabaseLifecycleState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutonomousDatabaseLifecycleState(input string) (*AutonomousDatabaseLifecycleState, error) { + vals := map[string]AutonomousDatabaseLifecycleState{ + "available": AutonomousDatabaseLifecycleStateAvailable, + "availableneedsattention": AutonomousDatabaseLifecycleStateAvailableNeedsAttention, + "backupinprogress": AutonomousDatabaseLifecycleStateBackupInProgress, + "inaccessible": AutonomousDatabaseLifecycleStateInaccessible, + "maintenanceinprogress": AutonomousDatabaseLifecycleStateMaintenanceInProgress, + "provisioning": AutonomousDatabaseLifecycleStateProvisioning, + "recreating": AutonomousDatabaseLifecycleStateRecreating, + "restarting": AutonomousDatabaseLifecycleStateRestarting, + "restorefailed": AutonomousDatabaseLifecycleStateRestoreFailed, + "restoreinprogress": AutonomousDatabaseLifecycleStateRestoreInProgress, + "rolechangeinprogress": AutonomousDatabaseLifecycleStateRoleChangeInProgress, + "scaleinprogress": AutonomousDatabaseLifecycleStateScaleInProgress, + "standby": AutonomousDatabaseLifecycleStateStandby, + "starting": AutonomousDatabaseLifecycleStateStarting, + "stopped": AutonomousDatabaseLifecycleStateStopped, + "stopping": AutonomousDatabaseLifecycleStateStopping, + "terminated": AutonomousDatabaseLifecycleStateTerminated, + "terminating": AutonomousDatabaseLifecycleStateTerminating, + "unavailable": AutonomousDatabaseLifecycleStateUnavailable, + "updating": AutonomousDatabaseLifecycleStateUpdating, + "upgrading": AutonomousDatabaseLifecycleStateUpgrading, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutonomousDatabaseLifecycleState(input) + return &out, nil +} + +type AutonomousMaintenanceScheduleType string + +const ( + AutonomousMaintenanceScheduleTypeEarly AutonomousMaintenanceScheduleType = "Early" + AutonomousMaintenanceScheduleTypeRegular AutonomousMaintenanceScheduleType = "Regular" +) + +func PossibleValuesForAutonomousMaintenanceScheduleType() []string { + return []string{ + string(AutonomousMaintenanceScheduleTypeEarly), + string(AutonomousMaintenanceScheduleTypeRegular), + } +} + +func (s *AutonomousMaintenanceScheduleType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutonomousMaintenanceScheduleType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutonomousMaintenanceScheduleType(input string) (*AutonomousMaintenanceScheduleType, error) { + vals := map[string]AutonomousMaintenanceScheduleType{ + "early": AutonomousMaintenanceScheduleTypeEarly, + "regular": AutonomousMaintenanceScheduleTypeRegular, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutonomousMaintenanceScheduleType(input) + return &out, nil +} + +type AzureResourceProvisioningState string + +const ( + AzureResourceProvisioningStateCanceled AzureResourceProvisioningState = "Canceled" + AzureResourceProvisioningStateFailed AzureResourceProvisioningState = "Failed" + AzureResourceProvisioningStateProvisioning AzureResourceProvisioningState = "Provisioning" + AzureResourceProvisioningStateSucceeded AzureResourceProvisioningState = "Succeeded" +) + +func PossibleValuesForAzureResourceProvisioningState() []string { + return []string{ + string(AzureResourceProvisioningStateCanceled), + string(AzureResourceProvisioningStateFailed), + string(AzureResourceProvisioningStateProvisioning), + string(AzureResourceProvisioningStateSucceeded), + } +} + +func (s *AzureResourceProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureResourceProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureResourceProvisioningState(input string) (*AzureResourceProvisioningState, error) { + vals := map[string]AzureResourceProvisioningState{ + "canceled": AzureResourceProvisioningStateCanceled, + "failed": AzureResourceProvisioningStateFailed, + "provisioning": AzureResourceProvisioningStateProvisioning, + "succeeded": AzureResourceProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureResourceProvisioningState(input) + return &out, nil +} + +type CloneType string + +const ( + CloneTypeFull CloneType = "Full" + CloneTypeMetadata CloneType = "Metadata" +) + +func PossibleValuesForCloneType() []string { + return []string{ + string(CloneTypeFull), + string(CloneTypeMetadata), + } +} + +func (s *CloneType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCloneType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCloneType(input string) (*CloneType, error) { + vals := map[string]CloneType{ + "full": CloneTypeFull, + "metadata": CloneTypeMetadata, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CloneType(input) + return &out, nil +} + +type ComputeModel string + +const ( + ComputeModelECPU ComputeModel = "ECPU" + ComputeModelOCPU ComputeModel = "OCPU" +) + +func PossibleValuesForComputeModel() []string { + return []string{ + string(ComputeModelECPU), + string(ComputeModelOCPU), + } +} + +func (s *ComputeModel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseComputeModel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseComputeModel(input string) (*ComputeModel, error) { + vals := map[string]ComputeModel{ + "ecpu": ComputeModelECPU, + "ocpu": ComputeModelOCPU, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ComputeModel(input) + return &out, nil +} + +type ConsumerGroup string + +const ( + ConsumerGroupHigh ConsumerGroup = "High" + ConsumerGroupLow ConsumerGroup = "Low" + ConsumerGroupMedium ConsumerGroup = "Medium" + ConsumerGroupTp ConsumerGroup = "Tp" + ConsumerGroupTpurgent ConsumerGroup = "Tpurgent" +) + +func PossibleValuesForConsumerGroup() []string { + return []string{ + string(ConsumerGroupHigh), + string(ConsumerGroupLow), + string(ConsumerGroupMedium), + string(ConsumerGroupTp), + string(ConsumerGroupTpurgent), + } +} + +func (s *ConsumerGroup) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConsumerGroup(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConsumerGroup(input string) (*ConsumerGroup, error) { + vals := map[string]ConsumerGroup{ + "high": ConsumerGroupHigh, + "low": ConsumerGroupLow, + "medium": ConsumerGroupMedium, + "tp": ConsumerGroupTp, + "tpurgent": ConsumerGroupTpurgent, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConsumerGroup(input) + return &out, nil +} + +type DataBaseType string + +const ( + DataBaseTypeClone DataBaseType = "Clone" + DataBaseTypeRegular DataBaseType = "Regular" +) + +func PossibleValuesForDataBaseType() []string { + return []string{ + string(DataBaseTypeClone), + string(DataBaseTypeRegular), + } +} + +func (s *DataBaseType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDataBaseType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDataBaseType(input string) (*DataBaseType, error) { + vals := map[string]DataBaseType{ + "clone": DataBaseTypeClone, + "regular": DataBaseTypeRegular, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DataBaseType(input) + return &out, nil +} + +type DataSafeStatusType string + +const ( + DataSafeStatusTypeDeregistering DataSafeStatusType = "Deregistering" + DataSafeStatusTypeFailed DataSafeStatusType = "Failed" + DataSafeStatusTypeNotRegistered DataSafeStatusType = "NotRegistered" + DataSafeStatusTypeRegistered DataSafeStatusType = "Registered" + DataSafeStatusTypeRegistering DataSafeStatusType = "Registering" +) + +func PossibleValuesForDataSafeStatusType() []string { + return []string{ + string(DataSafeStatusTypeDeregistering), + string(DataSafeStatusTypeFailed), + string(DataSafeStatusTypeNotRegistered), + string(DataSafeStatusTypeRegistered), + string(DataSafeStatusTypeRegistering), + } +} + +func (s *DataSafeStatusType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDataSafeStatusType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDataSafeStatusType(input string) (*DataSafeStatusType, error) { + vals := map[string]DataSafeStatusType{ + "deregistering": DataSafeStatusTypeDeregistering, + "failed": DataSafeStatusTypeFailed, + "notregistered": DataSafeStatusTypeNotRegistered, + "registered": DataSafeStatusTypeRegistered, + "registering": DataSafeStatusTypeRegistering, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DataSafeStatusType(input) + return &out, nil +} + +type DatabaseEditionType string + +const ( + DatabaseEditionTypeEnterpriseEdition DatabaseEditionType = "EnterpriseEdition" + DatabaseEditionTypeStandardEdition DatabaseEditionType = "StandardEdition" +) + +func PossibleValuesForDatabaseEditionType() []string { + return []string{ + string(DatabaseEditionTypeEnterpriseEdition), + string(DatabaseEditionTypeStandardEdition), + } +} + +func (s *DatabaseEditionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDatabaseEditionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDatabaseEditionType(input string) (*DatabaseEditionType, error) { + vals := map[string]DatabaseEditionType{ + "enterpriseedition": DatabaseEditionTypeEnterpriseEdition, + "standardedition": DatabaseEditionTypeStandardEdition, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DatabaseEditionType(input) + return &out, nil +} + +type DayOfWeekName string + +const ( + DayOfWeekNameFriday DayOfWeekName = "Friday" + DayOfWeekNameMonday DayOfWeekName = "Monday" + DayOfWeekNameSaturday DayOfWeekName = "Saturday" + DayOfWeekNameSunday DayOfWeekName = "Sunday" + DayOfWeekNameThursday DayOfWeekName = "Thursday" + DayOfWeekNameTuesday DayOfWeekName = "Tuesday" + DayOfWeekNameWednesday DayOfWeekName = "Wednesday" +) + +func PossibleValuesForDayOfWeekName() []string { + return []string{ + string(DayOfWeekNameFriday), + string(DayOfWeekNameMonday), + string(DayOfWeekNameSaturday), + string(DayOfWeekNameSunday), + string(DayOfWeekNameThursday), + string(DayOfWeekNameTuesday), + string(DayOfWeekNameWednesday), + } +} + +func (s *DayOfWeekName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDayOfWeekName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDayOfWeekName(input string) (*DayOfWeekName, error) { + vals := map[string]DayOfWeekName{ + "friday": DayOfWeekNameFriday, + "monday": DayOfWeekNameMonday, + "saturday": DayOfWeekNameSaturday, + "sunday": DayOfWeekNameSunday, + "thursday": DayOfWeekNameThursday, + "tuesday": DayOfWeekNameTuesday, + "wednesday": DayOfWeekNameWednesday, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DayOfWeekName(input) + return &out, nil +} + +type DisasterRecoveryType string + +const ( + DisasterRecoveryTypeAdg DisasterRecoveryType = "Adg" + DisasterRecoveryTypeBackupBased DisasterRecoveryType = "BackupBased" +) + +func PossibleValuesForDisasterRecoveryType() []string { + return []string{ + string(DisasterRecoveryTypeAdg), + string(DisasterRecoveryTypeBackupBased), + } +} + +func (s *DisasterRecoveryType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDisasterRecoveryType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDisasterRecoveryType(input string) (*DisasterRecoveryType, error) { + vals := map[string]DisasterRecoveryType{ + "adg": DisasterRecoveryTypeAdg, + "backupbased": DisasterRecoveryTypeBackupBased, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DisasterRecoveryType(input) + return &out, nil +} + +type GenerateType string + +const ( + GenerateTypeAll GenerateType = "All" + GenerateTypeSingle GenerateType = "Single" +) + +func PossibleValuesForGenerateType() []string { + return []string{ + string(GenerateTypeAll), + string(GenerateTypeSingle), + } +} + +func (s *GenerateType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGenerateType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGenerateType(input string) (*GenerateType, error) { + vals := map[string]GenerateType{ + "all": GenerateTypeAll, + "single": GenerateTypeSingle, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GenerateType(input) + return &out, nil +} + +type HostFormatType string + +const ( + HostFormatTypeFqdn HostFormatType = "Fqdn" + HostFormatTypeIP HostFormatType = "Ip" +) + +func PossibleValuesForHostFormatType() []string { + return []string{ + string(HostFormatTypeFqdn), + string(HostFormatTypeIP), + } +} + +func (s *HostFormatType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHostFormatType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHostFormatType(input string) (*HostFormatType, error) { + vals := map[string]HostFormatType{ + "fqdn": HostFormatTypeFqdn, + "ip": HostFormatTypeIP, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HostFormatType(input) + return &out, nil +} + +type LicenseModel string + +const ( + LicenseModelBringYourOwnLicense LicenseModel = "BringYourOwnLicense" + LicenseModelLicenseIncluded LicenseModel = "LicenseIncluded" +) + +func PossibleValuesForLicenseModel() []string { + return []string{ + string(LicenseModelBringYourOwnLicense), + string(LicenseModelLicenseIncluded), + } +} + +func (s *LicenseModel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLicenseModel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLicenseModel(input string) (*LicenseModel, error) { + vals := map[string]LicenseModel{ + "bringyourownlicense": LicenseModelBringYourOwnLicense, + "licenseincluded": LicenseModelLicenseIncluded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LicenseModel(input) + return &out, nil +} + +type OpenModeType string + +const ( + OpenModeTypeReadOnly OpenModeType = "ReadOnly" + OpenModeTypeReadWrite OpenModeType = "ReadWrite" +) + +func PossibleValuesForOpenModeType() []string { + return []string{ + string(OpenModeTypeReadOnly), + string(OpenModeTypeReadWrite), + } +} + +func (s *OpenModeType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOpenModeType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOpenModeType(input string) (*OpenModeType, error) { + vals := map[string]OpenModeType{ + "readonly": OpenModeTypeReadOnly, + "readwrite": OpenModeTypeReadWrite, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OpenModeType(input) + return &out, nil +} + +type OperationsInsightsStatusType string + +const ( + OperationsInsightsStatusTypeDisabling OperationsInsightsStatusType = "Disabling" + OperationsInsightsStatusTypeEnabled OperationsInsightsStatusType = "Enabled" + OperationsInsightsStatusTypeEnabling OperationsInsightsStatusType = "Enabling" + OperationsInsightsStatusTypeFailedDisabling OperationsInsightsStatusType = "FailedDisabling" + OperationsInsightsStatusTypeFailedEnabling OperationsInsightsStatusType = "FailedEnabling" + OperationsInsightsStatusTypeNotEnabled OperationsInsightsStatusType = "NotEnabled" +) + +func PossibleValuesForOperationsInsightsStatusType() []string { + return []string{ + string(OperationsInsightsStatusTypeDisabling), + string(OperationsInsightsStatusTypeEnabled), + string(OperationsInsightsStatusTypeEnabling), + string(OperationsInsightsStatusTypeFailedDisabling), + string(OperationsInsightsStatusTypeFailedEnabling), + string(OperationsInsightsStatusTypeNotEnabled), + } +} + +func (s *OperationsInsightsStatusType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOperationsInsightsStatusType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOperationsInsightsStatusType(input string) (*OperationsInsightsStatusType, error) { + vals := map[string]OperationsInsightsStatusType{ + "disabling": OperationsInsightsStatusTypeDisabling, + "enabled": OperationsInsightsStatusTypeEnabled, + "enabling": OperationsInsightsStatusTypeEnabling, + "faileddisabling": OperationsInsightsStatusTypeFailedDisabling, + "failedenabling": OperationsInsightsStatusTypeFailedEnabling, + "notenabled": OperationsInsightsStatusTypeNotEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OperationsInsightsStatusType(input) + return &out, nil +} + +type PermissionLevelType string + +const ( + PermissionLevelTypeRestricted PermissionLevelType = "Restricted" + PermissionLevelTypeUnrestricted PermissionLevelType = "Unrestricted" +) + +func PossibleValuesForPermissionLevelType() []string { + return []string{ + string(PermissionLevelTypeRestricted), + string(PermissionLevelTypeUnrestricted), + } +} + +func (s *PermissionLevelType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePermissionLevelType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePermissionLevelType(input string) (*PermissionLevelType, error) { + vals := map[string]PermissionLevelType{ + "restricted": PermissionLevelTypeRestricted, + "unrestricted": PermissionLevelTypeUnrestricted, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PermissionLevelType(input) + return &out, nil +} + +type ProtocolType string + +const ( + ProtocolTypeTCP ProtocolType = "TCP" + ProtocolTypeTCPS ProtocolType = "TCPS" +) + +func PossibleValuesForProtocolType() []string { + return []string{ + string(ProtocolTypeTCP), + string(ProtocolTypeTCPS), + } +} + +func (s *ProtocolType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProtocolType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProtocolType(input string) (*ProtocolType, error) { + vals := map[string]ProtocolType{ + "tcp": ProtocolTypeTCP, + "tcps": ProtocolTypeTCPS, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtocolType(input) + return &out, nil +} + +type RefreshableModelType string + +const ( + RefreshableModelTypeAutomatic RefreshableModelType = "Automatic" + RefreshableModelTypeManual RefreshableModelType = "Manual" +) + +func PossibleValuesForRefreshableModelType() []string { + return []string{ + string(RefreshableModelTypeAutomatic), + string(RefreshableModelTypeManual), + } +} + +func (s *RefreshableModelType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRefreshableModelType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRefreshableModelType(input string) (*RefreshableModelType, error) { + vals := map[string]RefreshableModelType{ + "automatic": RefreshableModelTypeAutomatic, + "manual": RefreshableModelTypeManual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RefreshableModelType(input) + return &out, nil +} + +type RefreshableStatusType string + +const ( + RefreshableStatusTypeNotRefreshing RefreshableStatusType = "NotRefreshing" + RefreshableStatusTypeRefreshing RefreshableStatusType = "Refreshing" +) + +func PossibleValuesForRefreshableStatusType() []string { + return []string{ + string(RefreshableStatusTypeNotRefreshing), + string(RefreshableStatusTypeRefreshing), + } +} + +func (s *RefreshableStatusType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRefreshableStatusType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRefreshableStatusType(input string) (*RefreshableStatusType, error) { + vals := map[string]RefreshableStatusType{ + "notrefreshing": RefreshableStatusTypeNotRefreshing, + "refreshing": RefreshableStatusTypeRefreshing, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RefreshableStatusType(input) + return &out, nil +} + +type RepeatCadenceType string + +const ( + RepeatCadenceTypeMonthly RepeatCadenceType = "Monthly" + RepeatCadenceTypeOneTime RepeatCadenceType = "OneTime" + RepeatCadenceTypeWeekly RepeatCadenceType = "Weekly" + RepeatCadenceTypeYearly RepeatCadenceType = "Yearly" +) + +func PossibleValuesForRepeatCadenceType() []string { + return []string{ + string(RepeatCadenceTypeMonthly), + string(RepeatCadenceTypeOneTime), + string(RepeatCadenceTypeWeekly), + string(RepeatCadenceTypeYearly), + } +} + +func (s *RepeatCadenceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRepeatCadenceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRepeatCadenceType(input string) (*RepeatCadenceType, error) { + vals := map[string]RepeatCadenceType{ + "monthly": RepeatCadenceTypeMonthly, + "onetime": RepeatCadenceTypeOneTime, + "weekly": RepeatCadenceTypeWeekly, + "yearly": RepeatCadenceTypeYearly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RepeatCadenceType(input) + return &out, nil +} + +type RoleType string + +const ( + RoleTypeBackupCopy RoleType = "BackupCopy" + RoleTypeDisabledStandby RoleType = "DisabledStandby" + RoleTypePrimary RoleType = "Primary" + RoleTypeSnapshotStandby RoleType = "SnapshotStandby" + RoleTypeStandby RoleType = "Standby" +) + +func PossibleValuesForRoleType() []string { + return []string{ + string(RoleTypeBackupCopy), + string(RoleTypeDisabledStandby), + string(RoleTypePrimary), + string(RoleTypeSnapshotStandby), + string(RoleTypeStandby), + } +} + +func (s *RoleType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRoleType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRoleType(input string) (*RoleType, error) { + vals := map[string]RoleType{ + "backupcopy": RoleTypeBackupCopy, + "disabledstandby": RoleTypeDisabledStandby, + "primary": RoleTypePrimary, + "snapshotstandby": RoleTypeSnapshotStandby, + "standby": RoleTypeStandby, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RoleType(input) + return &out, nil +} + +type SessionModeType string + +const ( + SessionModeTypeDirect SessionModeType = "Direct" + SessionModeTypeRedirect SessionModeType = "Redirect" +) + +func PossibleValuesForSessionModeType() []string { + return []string{ + string(SessionModeTypeDirect), + string(SessionModeTypeRedirect), + } +} + +func (s *SessionModeType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSessionModeType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSessionModeType(input string) (*SessionModeType, error) { + vals := map[string]SessionModeType{ + "direct": SessionModeTypeDirect, + "redirect": SessionModeTypeRedirect, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SessionModeType(input) + return &out, nil +} + +type SourceType string + +const ( + SourceTypeBackupFromId SourceType = "BackupFromId" + SourceTypeBackupFromTimestamp SourceType = "BackupFromTimestamp" + SourceTypeCloneToRefreshable SourceType = "CloneToRefreshable" + SourceTypeCrossRegionDataguard SourceType = "CrossRegionDataguard" + SourceTypeCrossRegionDisasterRecovery SourceType = "CrossRegionDisasterRecovery" + SourceTypeDatabase SourceType = "Database" + SourceTypeNone SourceType = "None" +) + +func PossibleValuesForSourceType() []string { + return []string{ + string(SourceTypeBackupFromId), + string(SourceTypeBackupFromTimestamp), + string(SourceTypeCloneToRefreshable), + string(SourceTypeCrossRegionDataguard), + string(SourceTypeCrossRegionDisasterRecovery), + string(SourceTypeDatabase), + string(SourceTypeNone), + } +} + +func (s *SourceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSourceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSourceType(input string) (*SourceType, error) { + vals := map[string]SourceType{ + "backupfromid": SourceTypeBackupFromId, + "backupfromtimestamp": SourceTypeBackupFromTimestamp, + "clonetorefreshable": SourceTypeCloneToRefreshable, + "crossregiondataguard": SourceTypeCrossRegionDataguard, + "crossregiondisasterrecovery": SourceTypeCrossRegionDisasterRecovery, + "database": SourceTypeDatabase, + "none": SourceTypeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SourceType(input) + return &out, nil +} + +type SyntaxFormatType string + +const ( + SyntaxFormatTypeEzconnect SyntaxFormatType = "Ezconnect" + SyntaxFormatTypeEzconnectplus SyntaxFormatType = "Ezconnectplus" + SyntaxFormatTypeLong SyntaxFormatType = "Long" +) + +func PossibleValuesForSyntaxFormatType() []string { + return []string{ + string(SyntaxFormatTypeEzconnect), + string(SyntaxFormatTypeEzconnectplus), + string(SyntaxFormatTypeLong), + } +} + +func (s *SyntaxFormatType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSyntaxFormatType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSyntaxFormatType(input string) (*SyntaxFormatType, error) { + vals := map[string]SyntaxFormatType{ + "ezconnect": SyntaxFormatTypeEzconnect, + "ezconnectplus": SyntaxFormatTypeEzconnectplus, + "long": SyntaxFormatTypeLong, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SyntaxFormatType(input) + return &out, nil +} + +type TlsAuthenticationType string + +const ( + TlsAuthenticationTypeMutual TlsAuthenticationType = "Mutual" + TlsAuthenticationTypeServer TlsAuthenticationType = "Server" +) + +func PossibleValuesForTlsAuthenticationType() []string { + return []string{ + string(TlsAuthenticationTypeMutual), + string(TlsAuthenticationTypeServer), + } +} + +func (s *TlsAuthenticationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTlsAuthenticationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTlsAuthenticationType(input string) (*TlsAuthenticationType, error) { + vals := map[string]TlsAuthenticationType{ + "mutual": TlsAuthenticationTypeMutual, + "server": TlsAuthenticationTypeServer, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TlsAuthenticationType(input) + return &out, nil +} + +type WorkloadType string + +const ( + WorkloadTypeAJD WorkloadType = "AJD" + WorkloadTypeAPEX WorkloadType = "APEX" + WorkloadTypeDW WorkloadType = "DW" + WorkloadTypeOLTP WorkloadType = "OLTP" +) + +func PossibleValuesForWorkloadType() []string { + return []string{ + string(WorkloadTypeAJD), + string(WorkloadTypeAPEX), + string(WorkloadTypeDW), + string(WorkloadTypeOLTP), + } +} + +func (s *WorkloadType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkloadType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkloadType(input string) (*WorkloadType, error) { + vals := map[string]WorkloadType{ + "ajd": WorkloadTypeAJD, + "apex": WorkloadTypeAPEX, + "dw": WorkloadTypeDW, + "oltp": WorkloadTypeOLTP, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkloadType(input) + return &out, nil +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/id_autonomousdatabase.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/id_autonomousdatabase.go new file mode 100644 index 00000000000..3bc8c7eb375 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/id_autonomousdatabase.go @@ -0,0 +1,130 @@ +package autonomousdatabases + +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(&AutonomousDatabaseId{}) +} + +var _ resourceids.ResourceId = &AutonomousDatabaseId{} + +// AutonomousDatabaseId is a struct representing the Resource ID for a Autonomous Database +type AutonomousDatabaseId struct { + SubscriptionId string + ResourceGroupName string + AutonomousDatabaseName string +} + +// NewAutonomousDatabaseID returns a new AutonomousDatabaseId struct +func NewAutonomousDatabaseID(subscriptionId string, resourceGroupName string, autonomousDatabaseName string) AutonomousDatabaseId { + return AutonomousDatabaseId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + AutonomousDatabaseName: autonomousDatabaseName, + } +} + +// ParseAutonomousDatabaseID parses 'input' into a AutonomousDatabaseId +func ParseAutonomousDatabaseID(input string) (*AutonomousDatabaseId, error) { + parser := resourceids.NewParserFromResourceIdType(&AutonomousDatabaseId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AutonomousDatabaseId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAutonomousDatabaseIDInsensitively parses 'input' case-insensitively into a AutonomousDatabaseId +// note: this method should only be used for API response data and not user input +func ParseAutonomousDatabaseIDInsensitively(input string) (*AutonomousDatabaseId, error) { + parser := resourceids.NewParserFromResourceIdType(&AutonomousDatabaseId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AutonomousDatabaseId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AutonomousDatabaseId) 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.AutonomousDatabaseName, ok = input.Parsed["autonomousDatabaseName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "autonomousDatabaseName", input) + } + + return nil +} + +// ValidateAutonomousDatabaseID checks that 'input' can be parsed as a Autonomous Database ID +func ValidateAutonomousDatabaseID(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 := ParseAutonomousDatabaseID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Autonomous Database ID +func (id AutonomousDatabaseId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Oracle.Database/autonomousDatabases/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.AutonomousDatabaseName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Autonomous Database ID +func (id AutonomousDatabaseId) 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("staticOracleDatabase", "Oracle.Database", "Oracle.Database"), + resourceids.StaticSegment("staticAutonomousDatabases", "autonomousDatabases", "autonomousDatabases"), + resourceids.UserSpecifiedSegment("autonomousDatabaseName", "autonomousDatabaseValue"), + } +} + +// String returns a human-readable description of this Autonomous Database ID +func (id AutonomousDatabaseId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Autonomous Database Name: %q", id.AutonomousDatabaseName), + } + return fmt.Sprintf("Autonomous Database (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/id_autonomousdatabase_test.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/id_autonomousdatabase_test.go new file mode 100644 index 00000000000..79d2f6cfe3a --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/id_autonomousdatabase_test.go @@ -0,0 +1,282 @@ +package autonomousdatabases + +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 = &AutonomousDatabaseId{} + +func TestNewAutonomousDatabaseID(t *testing.T) { + id := NewAutonomousDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "autonomousDatabaseValue") + + 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.AutonomousDatabaseName != "autonomousDatabaseValue" { + t.Fatalf("Expected %q but got %q for Segment 'AutonomousDatabaseName'", id.AutonomousDatabaseName, "autonomousDatabaseValue") + } +} + +func TestFormatAutonomousDatabaseID(t *testing.T) { + actual := NewAutonomousDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "autonomousDatabaseValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/autonomousDatabases/autonomousDatabaseValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAutonomousDatabaseID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AutonomousDatabaseId + }{ + { + // 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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/autonomousDatabases", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/autonomousDatabases/autonomousDatabaseValue", + Expected: &AutonomousDatabaseId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + AutonomousDatabaseName: "autonomousDatabaseValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/autonomousDatabases/autonomousDatabaseValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAutonomousDatabaseID(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.AutonomousDatabaseName != v.Expected.AutonomousDatabaseName { + t.Fatalf("Expected %q but got %q for AutonomousDatabaseName", v.Expected.AutonomousDatabaseName, actual.AutonomousDatabaseName) + } + + } +} + +func TestParseAutonomousDatabaseIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AutonomousDatabaseId + }{ + { + // 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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/autonomousDatabases", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe/aUtOnOmOuSdAtAbAsEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/autonomousDatabases/autonomousDatabaseValue", + Expected: &AutonomousDatabaseId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + AutonomousDatabaseName: "autonomousDatabaseValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/autonomousDatabases/autonomousDatabaseValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe/aUtOnOmOuSdAtAbAsEs/aUtOnOmOuSdAtAbAsEvAlUe", + Expected: &AutonomousDatabaseId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + AutonomousDatabaseName: "aUtOnOmOuSdAtAbAsEvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe/aUtOnOmOuSdAtAbAsEs/aUtOnOmOuSdAtAbAsEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAutonomousDatabaseIDInsensitively(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.AutonomousDatabaseName != v.Expected.AutonomousDatabaseName { + t.Fatalf("Expected %q but got %q for AutonomousDatabaseName", v.Expected.AutonomousDatabaseName, actual.AutonomousDatabaseName) + } + + } +} + +func TestSegmentsForAutonomousDatabaseId(t *testing.T) { + segments := AutonomousDatabaseId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AutonomousDatabaseId 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/oracledatabase/2024-06-01/autonomousdatabases/method_createorupdate.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/method_createorupdate.go new file mode 100644 index 00000000000..7ed7016c55f --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/method_createorupdate.go @@ -0,0 +1,75 @@ +package autonomousdatabases + +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 *AutonomousDatabase +} + +// CreateOrUpdate ... +func (c AutonomousDatabasesClient) CreateOrUpdate(ctx context.Context, id AutonomousDatabaseId, input AutonomousDatabase) (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 AutonomousDatabasesClient) CreateOrUpdateThenPoll(ctx context.Context, id AutonomousDatabaseId, input AutonomousDatabase) 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/oracledatabase/2024-06-01/autonomousdatabases/method_delete.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/method_delete.go new file mode 100644 index 00000000000..b2629b1ffd3 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/method_delete.go @@ -0,0 +1,70 @@ +package autonomousdatabases + +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 AutonomousDatabasesClient) Delete(ctx context.Context, id AutonomousDatabaseId) (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 AutonomousDatabasesClient) DeleteThenPoll(ctx context.Context, id AutonomousDatabaseId) 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/oracledatabase/2024-06-01/autonomousdatabases/method_failover.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/method_failover.go new file mode 100644 index 00000000000..ddad3887688 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/method_failover.go @@ -0,0 +1,75 @@ +package autonomousdatabases + +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 FailoverOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AutonomousDatabase +} + +// Failover ... +func (c AutonomousDatabasesClient) Failover(ctx context.Context, id AutonomousDatabaseId, input PeerDbDetails) (result FailoverOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/failover", 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 +} + +// FailoverThenPoll performs Failover then polls until it's completed +func (c AutonomousDatabasesClient) FailoverThenPoll(ctx context.Context, id AutonomousDatabaseId, input PeerDbDetails) error { + result, err := c.Failover(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Failover: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Failover: %+v", err) + } + + return nil +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/method_generatewallet.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/method_generatewallet.go new file mode 100644 index 00000000000..009eacf5521 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/method_generatewallet.go @@ -0,0 +1,59 @@ +package autonomousdatabases + +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 GenerateWalletOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AutonomousDatabaseWalletFile +} + +// GenerateWallet ... +func (c AutonomousDatabasesClient) GenerateWallet(ctx context.Context, id AutonomousDatabaseId, input GenerateAutonomousDatabaseWalletDetails) (result GenerateWalletOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/generateWallet", 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 AutonomousDatabaseWalletFile + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/method_get.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/method_get.go new file mode 100644 index 00000000000..c95b6d3808a --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/method_get.go @@ -0,0 +1,54 @@ +package autonomousdatabases + +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 *AutonomousDatabase +} + +// Get ... +func (c AutonomousDatabasesClient) Get(ctx context.Context, id AutonomousDatabaseId) (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 AutonomousDatabase + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/method_listbyresourcegroup.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/method_listbyresourcegroup.go new file mode 100644 index 00000000000..fb66603459b --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package autonomousdatabases + +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 *[]AutonomousDatabase +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []AutonomousDatabase +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c AutonomousDatabasesClient) 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, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Oracle.Database/autonomousDatabases", 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 *[]AutonomousDatabase `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 AutonomousDatabasesClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, AutonomousDatabaseOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AutonomousDatabasesClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate AutonomousDatabaseOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]AutonomousDatabase, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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/oracledatabase/2024-06-01/autonomousdatabases/method_listbysubscription.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/method_listbysubscription.go new file mode 100644 index 00000000000..1cfc10b0488 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/method_listbysubscription.go @@ -0,0 +1,106 @@ +package autonomousdatabases + +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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AutonomousDatabase +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []AutonomousDatabase +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c AutonomousDatabasesClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Oracle.Database/autonomousDatabases", 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 *[]AutonomousDatabase `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c AutonomousDatabasesClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, AutonomousDatabaseOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AutonomousDatabasesClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate AutonomousDatabaseOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]AutonomousDatabase, 0) + + resp, err := c.ListBySubscription(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/method_restore.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/method_restore.go new file mode 100644 index 00000000000..c6e860c8c2d --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/method_restore.go @@ -0,0 +1,75 @@ +package autonomousdatabases + +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 RestoreOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AutonomousDatabase +} + +// Restore ... +func (c AutonomousDatabasesClient) Restore(ctx context.Context, id AutonomousDatabaseId, input RestoreAutonomousDatabaseDetails) (result RestoreOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restore", 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 +} + +// RestoreThenPoll performs Restore then polls until it's completed +func (c AutonomousDatabasesClient) RestoreThenPoll(ctx context.Context, id AutonomousDatabaseId, input RestoreAutonomousDatabaseDetails) error { + result, err := c.Restore(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Restore: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Restore: %+v", err) + } + + return nil +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/method_shrink.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/method_shrink.go new file mode 100644 index 00000000000..baed1bbf367 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/method_shrink.go @@ -0,0 +1,71 @@ +package autonomousdatabases + +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 ShrinkOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AutonomousDatabase +} + +// Shrink ... +func (c AutonomousDatabasesClient) Shrink(ctx context.Context, id AutonomousDatabaseId) (result ShrinkOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/shrink", 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 +} + +// ShrinkThenPoll performs Shrink then polls until it's completed +func (c AutonomousDatabasesClient) ShrinkThenPoll(ctx context.Context, id AutonomousDatabaseId) error { + result, err := c.Shrink(ctx, id) + if err != nil { + return fmt.Errorf("performing Shrink: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Shrink: %+v", err) + } + + return nil +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/method_switchover.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/method_switchover.go new file mode 100644 index 00000000000..8b21a43f851 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/method_switchover.go @@ -0,0 +1,75 @@ +package autonomousdatabases + +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 SwitchoverOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AutonomousDatabase +} + +// Switchover ... +func (c AutonomousDatabasesClient) Switchover(ctx context.Context, id AutonomousDatabaseId, input PeerDbDetails) (result SwitchoverOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/switchover", 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 +} + +// SwitchoverThenPoll performs Switchover then polls until it's completed +func (c AutonomousDatabasesClient) SwitchoverThenPoll(ctx context.Context, id AutonomousDatabaseId, input PeerDbDetails) error { + result, err := c.Switchover(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Switchover: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Switchover: %+v", err) + } + + return nil +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/method_update.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/method_update.go new file mode 100644 index 00000000000..dea97562d89 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/method_update.go @@ -0,0 +1,75 @@ +package autonomousdatabases + +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 *AutonomousDatabase +} + +// Update ... +func (c AutonomousDatabasesClient) Update(ctx context.Context, id AutonomousDatabaseId, input AutonomousDatabaseUpdate) (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 AutonomousDatabasesClient) UpdateThenPoll(ctx context.Context, id AutonomousDatabaseId, input AutonomousDatabaseUpdate) 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/oracledatabase/2024-06-01/autonomousdatabases/model_allconnectionstringtype.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_allconnectionstringtype.go new file mode 100644 index 00000000000..a0c89f0608f --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_allconnectionstringtype.go @@ -0,0 +1,10 @@ +package autonomousdatabases + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AllConnectionStringType struct { + High *string `json:"high,omitempty"` + Low *string `json:"low,omitempty"` + Medium *string `json:"medium,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_apexdetailstype.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_apexdetailstype.go new file mode 100644 index 00000000000..420d585f5d1 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_apexdetailstype.go @@ -0,0 +1,9 @@ +package autonomousdatabases + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApexDetailsType struct { + ApexVersion *string `json:"apexVersion,omitempty"` + OrdsVersion *string `json:"ordsVersion,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_autonomousdatabase.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_autonomousdatabase.go new file mode 100644 index 00000000000..b30cc01b078 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_autonomousdatabase.go @@ -0,0 +1,52 @@ +package autonomousdatabases + +import ( + "encoding/json" + "fmt" + + "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 AutonomousDatabase struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties AutonomousDatabaseBaseProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &AutonomousDatabase{} + +func (s *AutonomousDatabase) UnmarshalJSON(bytes []byte) error { + type alias AutonomousDatabase + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into AutonomousDatabase: %+v", err) + } + + s.Id = decoded.Id + s.Location = decoded.Location + s.Name = decoded.Name + s.SystemData = decoded.SystemData + s.Tags = decoded.Tags + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling AutonomousDatabase into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalAutonomousDatabaseBasePropertiesImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'AutonomousDatabase': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_autonomousdatabasebaseproperties.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_autonomousdatabasebaseproperties.go new file mode 100644 index 00000000000..90c25e5dff6 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_autonomousdatabasebaseproperties.go @@ -0,0 +1,61 @@ +package autonomousdatabases + +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 AutonomousDatabaseBaseProperties interface { +} + +// RawAutonomousDatabaseBasePropertiesImpl is returned when the Discriminated Value +// doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawAutonomousDatabaseBasePropertiesImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalAutonomousDatabaseBasePropertiesImplementation(input []byte) (AutonomousDatabaseBaseProperties, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling AutonomousDatabaseBaseProperties into map[string]interface: %+v", err) + } + + value, ok := temp["dataBaseType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "Clone") { + var out AutonomousDatabaseCloneProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AutonomousDatabaseCloneProperties: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Regular") { + var out AutonomousDatabaseProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AutonomousDatabaseProperties: %+v", err) + } + return out, nil + } + + out := RawAutonomousDatabaseBasePropertiesImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_autonomousdatabasecloneproperties.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_autonomousdatabasecloneproperties.go new file mode 100644 index 00000000000..5b5fd9fdbe9 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_autonomousdatabasecloneproperties.go @@ -0,0 +1,173 @@ +package autonomousdatabases + +import ( + "encoding/json" + "fmt" + "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. + +var _ AutonomousDatabaseBaseProperties = AutonomousDatabaseCloneProperties{} + +type AutonomousDatabaseCloneProperties struct { + CloneType CloneType `json:"cloneType"` + IsReconnectCloneEnabled *bool `json:"isReconnectCloneEnabled,omitempty"` + IsRefreshableClone *bool `json:"isRefreshableClone,omitempty"` + RefreshableModel *RefreshableModelType `json:"refreshableModel,omitempty"` + RefreshableStatus *RefreshableStatusType `json:"refreshableStatus,omitempty"` + Source *SourceType `json:"source,omitempty"` + SourceId string `json:"sourceId"` + TimeUntilReconnectCloneEnabled *string `json:"timeUntilReconnectCloneEnabled,omitempty"` + + // Fields inherited from AutonomousDatabaseBaseProperties + ActualUsedDataStorageSizeInTbs *float64 `json:"actualUsedDataStorageSizeInTbs,omitempty"` + AdminPassword *string `json:"adminPassword,omitempty"` + AllocatedStorageSizeInTbs *float64 `json:"allocatedStorageSizeInTbs,omitempty"` + ApexDetails *ApexDetailsType `json:"apexDetails,omitempty"` + AutonomousDatabaseId *string `json:"autonomousDatabaseId,omitempty"` + AutonomousMaintenanceScheduleType *AutonomousMaintenanceScheduleType `json:"autonomousMaintenanceScheduleType,omitempty"` + AvailableUpgradeVersions *[]string `json:"availableUpgradeVersions,omitempty"` + BackupRetentionPeriodInDays *int64 `json:"backupRetentionPeriodInDays,omitempty"` + CharacterSet *string `json:"characterSet,omitempty"` + ComputeCount *float64 `json:"computeCount,omitempty"` + ComputeModel *ComputeModel `json:"computeModel,omitempty"` + ConnectionStrings *ConnectionStringType `json:"connectionStrings,omitempty"` + ConnectionUrls *ConnectionUrlType `json:"connectionUrls,omitempty"` + CpuCoreCount *int64 `json:"cpuCoreCount,omitempty"` + CustomerContacts *[]CustomerContact `json:"customerContacts,omitempty"` + DataSafeStatus *DataSafeStatusType `json:"dataSafeStatus,omitempty"` + DataStorageSizeInGbs *int64 `json:"dataStorageSizeInGbs,omitempty"` + DataStorageSizeInTbs *int64 `json:"dataStorageSizeInTbs,omitempty"` + DatabaseEdition *DatabaseEditionType `json:"databaseEdition,omitempty"` + DbVersion *string `json:"dbVersion,omitempty"` + DbWorkload *WorkloadType `json:"dbWorkload,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + FailedDataRecoveryInSeconds *int64 `json:"failedDataRecoveryInSeconds,omitempty"` + InMemoryAreaInGbs *int64 `json:"inMemoryAreaInGbs,omitempty"` + IsAutoScalingEnabled *bool `json:"isAutoScalingEnabled,omitempty"` + IsAutoScalingForStorageEnabled *bool `json:"isAutoScalingForStorageEnabled,omitempty"` + IsLocalDataGuardEnabled *bool `json:"isLocalDataGuardEnabled,omitempty"` + IsMtlsConnectionRequired *bool `json:"isMtlsConnectionRequired,omitempty"` + IsPreview *bool `json:"isPreview,omitempty"` + IsPreviewVersionWithServiceTermsAccepted *bool `json:"isPreviewVersionWithServiceTermsAccepted,omitempty"` + IsRemoteDataGuardEnabled *bool `json:"isRemoteDataGuardEnabled,omitempty"` + LicenseModel *LicenseModel `json:"licenseModel,omitempty"` + LifecycleDetails *string `json:"lifecycleDetails,omitempty"` + LifecycleState *AutonomousDatabaseLifecycleState `json:"lifecycleState,omitempty"` + LocalAdgAutoFailoverMaxDataLossLimit *int64 `json:"localAdgAutoFailoverMaxDataLossLimit,omitempty"` + LocalDisasterRecoveryType *DisasterRecoveryType `json:"localDisasterRecoveryType,omitempty"` + LocalStandbyDb *AutonomousDatabaseStandbySummary `json:"localStandbyDb,omitempty"` + LongTermBackupSchedule *LongTermBackUpScheduleDetails `json:"longTermBackupSchedule,omitempty"` + MemoryPerOracleComputeUnitInGbs *int64 `json:"memoryPerOracleComputeUnitInGbs,omitempty"` + NcharacterSet *string `json:"ncharacterSet,omitempty"` + NextLongTermBackupTimeStamp *string `json:"nextLongTermBackupTimeStamp,omitempty"` + OciUrl *string `json:"ociUrl,omitempty"` + Ocid *string `json:"ocid,omitempty"` + OpenMode *OpenModeType `json:"openMode,omitempty"` + OperationsInsightsStatus *OperationsInsightsStatusType `json:"operationsInsightsStatus,omitempty"` + PeerDbId *string `json:"peerDbId,omitempty"` + PeerDbIds *[]string `json:"peerDbIds,omitempty"` + PermissionLevel *PermissionLevelType `json:"permissionLevel,omitempty"` + PrivateEndpoint *string `json:"privateEndpoint,omitempty"` + PrivateEndpointIP *string `json:"privateEndpointIp,omitempty"` + PrivateEndpointLabel *string `json:"privateEndpointLabel,omitempty"` + ProvisionableCPUs *[]int64 `json:"provisionableCpus,omitempty"` + ProvisioningState *AzureResourceProvisioningState `json:"provisioningState,omitempty"` + Role *RoleType `json:"role,omitempty"` + ScheduledOperations *ScheduledOperationsType `json:"scheduledOperations,omitempty"` + ServiceConsoleUrl *string `json:"serviceConsoleUrl,omitempty"` + SqlWebDeveloperUrl *string `json:"sqlWebDeveloperUrl,omitempty"` + SubnetId *string `json:"subnetId,omitempty"` + SupportedRegionsToCloneTo *[]string `json:"supportedRegionsToCloneTo,omitempty"` + TimeCreated *string `json:"timeCreated,omitempty"` + TimeDataGuardRoleChanged *string `json:"timeDataGuardRoleChanged,omitempty"` + TimeDeletionOfFreeAutonomousDatabase *string `json:"timeDeletionOfFreeAutonomousDatabase,omitempty"` + TimeLocalDataGuardEnabled *string `json:"timeLocalDataGuardEnabled,omitempty"` + TimeMaintenanceBegin *string `json:"timeMaintenanceBegin,omitempty"` + TimeMaintenanceEnd *string `json:"timeMaintenanceEnd,omitempty"` + TimeOfLastFailover *string `json:"timeOfLastFailover,omitempty"` + TimeOfLastRefresh *string `json:"timeOfLastRefresh,omitempty"` + TimeOfLastRefreshPoint *string `json:"timeOfLastRefreshPoint,omitempty"` + TimeOfLastSwitchover *string `json:"timeOfLastSwitchover,omitempty"` + TimeReclamationOfFreeAutonomousDatabase *string `json:"timeReclamationOfFreeAutonomousDatabase,omitempty"` + UsedDataStorageSizeInGbs *int64 `json:"usedDataStorageSizeInGbs,omitempty"` + UsedDataStorageSizeInTbs *int64 `json:"usedDataStorageSizeInTbs,omitempty"` + VnetId *string `json:"vnetId,omitempty"` + WhitelistedIPs *[]string `json:"whitelistedIps,omitempty"` +} + +func (o *AutonomousDatabaseCloneProperties) GetNextLongTermBackupTimeStampAsTime() (*time.Time, error) { + if o.NextLongTermBackupTimeStamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NextLongTermBackupTimeStamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *AutonomousDatabaseCloneProperties) SetNextLongTermBackupTimeStampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NextLongTermBackupTimeStamp = &formatted +} + +func (o *AutonomousDatabaseCloneProperties) GetTimeCreatedAsTime() (*time.Time, error) { + if o.TimeCreated == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeCreated, "2006-01-02T15:04:05Z07:00") +} + +func (o *AutonomousDatabaseCloneProperties) SetTimeCreatedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeCreated = &formatted +} + +func (o *AutonomousDatabaseCloneProperties) GetTimeMaintenanceBeginAsTime() (*time.Time, error) { + if o.TimeMaintenanceBegin == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeMaintenanceBegin, "2006-01-02T15:04:05Z07:00") +} + +func (o *AutonomousDatabaseCloneProperties) SetTimeMaintenanceBeginAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeMaintenanceBegin = &formatted +} + +func (o *AutonomousDatabaseCloneProperties) GetTimeMaintenanceEndAsTime() (*time.Time, error) { + if o.TimeMaintenanceEnd == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeMaintenanceEnd, "2006-01-02T15:04:05Z07:00") +} + +func (o *AutonomousDatabaseCloneProperties) SetTimeMaintenanceEndAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeMaintenanceEnd = &formatted +} + +var _ json.Marshaler = AutonomousDatabaseCloneProperties{} + +func (s AutonomousDatabaseCloneProperties) MarshalJSON() ([]byte, error) { + type wrapper AutonomousDatabaseCloneProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AutonomousDatabaseCloneProperties: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AutonomousDatabaseCloneProperties: %+v", err) + } + decoded["dataBaseType"] = "Clone" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AutonomousDatabaseCloneProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_autonomousdatabaseproperties.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_autonomousdatabaseproperties.go new file mode 100644 index 00000000000..9a10d4134bc --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_autonomousdatabaseproperties.go @@ -0,0 +1,165 @@ +package autonomousdatabases + +import ( + "encoding/json" + "fmt" + "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. + +var _ AutonomousDatabaseBaseProperties = AutonomousDatabaseProperties{} + +type AutonomousDatabaseProperties struct { + + // Fields inherited from AutonomousDatabaseBaseProperties + ActualUsedDataStorageSizeInTbs *float64 `json:"actualUsedDataStorageSizeInTbs,omitempty"` + AdminPassword *string `json:"adminPassword,omitempty"` + AllocatedStorageSizeInTbs *float64 `json:"allocatedStorageSizeInTbs,omitempty"` + ApexDetails *ApexDetailsType `json:"apexDetails,omitempty"` + AutonomousDatabaseId *string `json:"autonomousDatabaseId,omitempty"` + AutonomousMaintenanceScheduleType *AutonomousMaintenanceScheduleType `json:"autonomousMaintenanceScheduleType,omitempty"` + AvailableUpgradeVersions *[]string `json:"availableUpgradeVersions,omitempty"` + BackupRetentionPeriodInDays *int64 `json:"backupRetentionPeriodInDays,omitempty"` + CharacterSet *string `json:"characterSet,omitempty"` + ComputeCount *float64 `json:"computeCount,omitempty"` + ComputeModel *ComputeModel `json:"computeModel,omitempty"` + ConnectionStrings *ConnectionStringType `json:"connectionStrings,omitempty"` + ConnectionUrls *ConnectionUrlType `json:"connectionUrls,omitempty"` + CpuCoreCount *int64 `json:"cpuCoreCount,omitempty"` + CustomerContacts *[]CustomerContact `json:"customerContacts,omitempty"` + DataSafeStatus *DataSafeStatusType `json:"dataSafeStatus,omitempty"` + DataStorageSizeInGbs *int64 `json:"dataStorageSizeInGbs,omitempty"` + DataStorageSizeInTbs *int64 `json:"dataStorageSizeInTbs,omitempty"` + DatabaseEdition *DatabaseEditionType `json:"databaseEdition,omitempty"` + DbVersion *string `json:"dbVersion,omitempty"` + DbWorkload *WorkloadType `json:"dbWorkload,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + FailedDataRecoveryInSeconds *int64 `json:"failedDataRecoveryInSeconds,omitempty"` + InMemoryAreaInGbs *int64 `json:"inMemoryAreaInGbs,omitempty"` + IsAutoScalingEnabled *bool `json:"isAutoScalingEnabled,omitempty"` + IsAutoScalingForStorageEnabled *bool `json:"isAutoScalingForStorageEnabled,omitempty"` + IsLocalDataGuardEnabled *bool `json:"isLocalDataGuardEnabled,omitempty"` + IsMtlsConnectionRequired *bool `json:"isMtlsConnectionRequired,omitempty"` + IsPreview *bool `json:"isPreview,omitempty"` + IsPreviewVersionWithServiceTermsAccepted *bool `json:"isPreviewVersionWithServiceTermsAccepted,omitempty"` + IsRemoteDataGuardEnabled *bool `json:"isRemoteDataGuardEnabled,omitempty"` + LicenseModel *LicenseModel `json:"licenseModel,omitempty"` + LifecycleDetails *string `json:"lifecycleDetails,omitempty"` + LifecycleState *AutonomousDatabaseLifecycleState `json:"lifecycleState,omitempty"` + LocalAdgAutoFailoverMaxDataLossLimit *int64 `json:"localAdgAutoFailoverMaxDataLossLimit,omitempty"` + LocalDisasterRecoveryType *DisasterRecoveryType `json:"localDisasterRecoveryType,omitempty"` + LocalStandbyDb *AutonomousDatabaseStandbySummary `json:"localStandbyDb,omitempty"` + LongTermBackupSchedule *LongTermBackUpScheduleDetails `json:"longTermBackupSchedule,omitempty"` + MemoryPerOracleComputeUnitInGbs *int64 `json:"memoryPerOracleComputeUnitInGbs,omitempty"` + NcharacterSet *string `json:"ncharacterSet,omitempty"` + NextLongTermBackupTimeStamp *string `json:"nextLongTermBackupTimeStamp,omitempty"` + OciUrl *string `json:"ociUrl,omitempty"` + Ocid *string `json:"ocid,omitempty"` + OpenMode *OpenModeType `json:"openMode,omitempty"` + OperationsInsightsStatus *OperationsInsightsStatusType `json:"operationsInsightsStatus,omitempty"` + PeerDbId *string `json:"peerDbId,omitempty"` + PeerDbIds *[]string `json:"peerDbIds,omitempty"` + PermissionLevel *PermissionLevelType `json:"permissionLevel,omitempty"` + PrivateEndpoint *string `json:"privateEndpoint,omitempty"` + PrivateEndpointIP *string `json:"privateEndpointIp,omitempty"` + PrivateEndpointLabel *string `json:"privateEndpointLabel,omitempty"` + ProvisionableCPUs *[]int64 `json:"provisionableCpus,omitempty"` + ProvisioningState *AzureResourceProvisioningState `json:"provisioningState,omitempty"` + Role *RoleType `json:"role,omitempty"` + ScheduledOperations *ScheduledOperationsType `json:"scheduledOperations,omitempty"` + ServiceConsoleUrl *string `json:"serviceConsoleUrl,omitempty"` + SqlWebDeveloperUrl *string `json:"sqlWebDeveloperUrl,omitempty"` + SubnetId *string `json:"subnetId,omitempty"` + SupportedRegionsToCloneTo *[]string `json:"supportedRegionsToCloneTo,omitempty"` + TimeCreated *string `json:"timeCreated,omitempty"` + TimeDataGuardRoleChanged *string `json:"timeDataGuardRoleChanged,omitempty"` + TimeDeletionOfFreeAutonomousDatabase *string `json:"timeDeletionOfFreeAutonomousDatabase,omitempty"` + TimeLocalDataGuardEnabled *string `json:"timeLocalDataGuardEnabled,omitempty"` + TimeMaintenanceBegin *string `json:"timeMaintenanceBegin,omitempty"` + TimeMaintenanceEnd *string `json:"timeMaintenanceEnd,omitempty"` + TimeOfLastFailover *string `json:"timeOfLastFailover,omitempty"` + TimeOfLastRefresh *string `json:"timeOfLastRefresh,omitempty"` + TimeOfLastRefreshPoint *string `json:"timeOfLastRefreshPoint,omitempty"` + TimeOfLastSwitchover *string `json:"timeOfLastSwitchover,omitempty"` + TimeReclamationOfFreeAutonomousDatabase *string `json:"timeReclamationOfFreeAutonomousDatabase,omitempty"` + UsedDataStorageSizeInGbs *int64 `json:"usedDataStorageSizeInGbs,omitempty"` + UsedDataStorageSizeInTbs *int64 `json:"usedDataStorageSizeInTbs,omitempty"` + VnetId *string `json:"vnetId,omitempty"` + WhitelistedIPs *[]string `json:"whitelistedIps,omitempty"` +} + +func (o *AutonomousDatabaseProperties) GetNextLongTermBackupTimeStampAsTime() (*time.Time, error) { + if o.NextLongTermBackupTimeStamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NextLongTermBackupTimeStamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *AutonomousDatabaseProperties) SetNextLongTermBackupTimeStampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NextLongTermBackupTimeStamp = &formatted +} + +func (o *AutonomousDatabaseProperties) GetTimeCreatedAsTime() (*time.Time, error) { + if o.TimeCreated == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeCreated, "2006-01-02T15:04:05Z07:00") +} + +func (o *AutonomousDatabaseProperties) SetTimeCreatedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeCreated = &formatted +} + +func (o *AutonomousDatabaseProperties) GetTimeMaintenanceBeginAsTime() (*time.Time, error) { + if o.TimeMaintenanceBegin == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeMaintenanceBegin, "2006-01-02T15:04:05Z07:00") +} + +func (o *AutonomousDatabaseProperties) SetTimeMaintenanceBeginAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeMaintenanceBegin = &formatted +} + +func (o *AutonomousDatabaseProperties) GetTimeMaintenanceEndAsTime() (*time.Time, error) { + if o.TimeMaintenanceEnd == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeMaintenanceEnd, "2006-01-02T15:04:05Z07:00") +} + +func (o *AutonomousDatabaseProperties) SetTimeMaintenanceEndAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeMaintenanceEnd = &formatted +} + +var _ json.Marshaler = AutonomousDatabaseProperties{} + +func (s AutonomousDatabaseProperties) MarshalJSON() ([]byte, error) { + type wrapper AutonomousDatabaseProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AutonomousDatabaseProperties: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AutonomousDatabaseProperties: %+v", err) + } + decoded["dataBaseType"] = "Regular" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AutonomousDatabaseProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_autonomousdatabasestandbysummary.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_autonomousdatabasestandbysummary.go new file mode 100644 index 00000000000..484d3578c68 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_autonomousdatabasestandbysummary.go @@ -0,0 +1,12 @@ +package autonomousdatabases + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutonomousDatabaseStandbySummary struct { + LagTimeInSeconds *int64 `json:"lagTimeInSeconds,omitempty"` + LifecycleDetails *string `json:"lifecycleDetails,omitempty"` + LifecycleState *AutonomousDatabaseLifecycleState `json:"lifecycleState,omitempty"` + TimeDataGuardRoleChanged *string `json:"timeDataGuardRoleChanged,omitempty"` + TimeDisasterRecoveryRoleChanged *string `json:"timeDisasterRecoveryRoleChanged,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_autonomousdatabaseupdate.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_autonomousdatabaseupdate.go new file mode 100644 index 00000000000..d4087756731 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_autonomousdatabaseupdate.go @@ -0,0 +1,9 @@ +package autonomousdatabases + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutonomousDatabaseUpdate struct { + Properties *AutonomousDatabaseUpdateProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_autonomousdatabaseupdateproperties.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_autonomousdatabaseupdateproperties.go new file mode 100644 index 00000000000..d3acaf86893 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_autonomousdatabaseupdateproperties.go @@ -0,0 +1,30 @@ +package autonomousdatabases + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutonomousDatabaseUpdateProperties struct { + AdminPassword *string `json:"adminPassword,omitempty"` + AutonomousMaintenanceScheduleType *AutonomousMaintenanceScheduleType `json:"autonomousMaintenanceScheduleType,omitempty"` + BackupRetentionPeriodInDays *int64 `json:"backupRetentionPeriodInDays,omitempty"` + ComputeCount *float64 `json:"computeCount,omitempty"` + CpuCoreCount *int64 `json:"cpuCoreCount,omitempty"` + CustomerContacts *[]CustomerContact `json:"customerContacts,omitempty"` + DataStorageSizeInGbs *int64 `json:"dataStorageSizeInGbs,omitempty"` + DataStorageSizeInTbs *int64 `json:"dataStorageSizeInTbs,omitempty"` + DatabaseEdition *DatabaseEditionType `json:"databaseEdition,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + IsAutoScalingEnabled *bool `json:"isAutoScalingEnabled,omitempty"` + IsAutoScalingForStorageEnabled *bool `json:"isAutoScalingForStorageEnabled,omitempty"` + IsLocalDataGuardEnabled *bool `json:"isLocalDataGuardEnabled,omitempty"` + IsMtlsConnectionRequired *bool `json:"isMtlsConnectionRequired,omitempty"` + LicenseModel *LicenseModel `json:"licenseModel,omitempty"` + LocalAdgAutoFailoverMaxDataLossLimit *int64 `json:"localAdgAutoFailoverMaxDataLossLimit,omitempty"` + LongTermBackupSchedule *LongTermBackUpScheduleDetails `json:"longTermBackupSchedule,omitempty"` + OpenMode *OpenModeType `json:"openMode,omitempty"` + PeerDbId *string `json:"peerDbId,omitempty"` + PermissionLevel *PermissionLevelType `json:"permissionLevel,omitempty"` + Role *RoleType `json:"role,omitempty"` + ScheduledOperations *ScheduledOperationsTypeUpdate `json:"scheduledOperations,omitempty"` + WhitelistedIPs *[]string `json:"whitelistedIps,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_autonomousdatabasewalletfile.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_autonomousdatabasewalletfile.go new file mode 100644 index 00000000000..3db16ef5d70 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_autonomousdatabasewalletfile.go @@ -0,0 +1,8 @@ +package autonomousdatabases + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutonomousDatabaseWalletFile struct { + WalletFiles string `json:"walletFiles"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_connectionstringtype.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_connectionstringtype.go new file mode 100644 index 00000000000..044b93601aa --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_connectionstringtype.go @@ -0,0 +1,13 @@ +package autonomousdatabases + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectionStringType struct { + AllConnectionStrings *AllConnectionStringType `json:"allConnectionStrings,omitempty"` + Dedicated *string `json:"dedicated,omitempty"` + High *string `json:"high,omitempty"` + Low *string `json:"low,omitempty"` + Medium *string `json:"medium,omitempty"` + Profiles *[]ProfileType `json:"profiles,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_connectionurltype.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_connectionurltype.go new file mode 100644 index 00000000000..0c2c730e4cf --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_connectionurltype.go @@ -0,0 +1,14 @@ +package autonomousdatabases + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectionUrlType struct { + ApexUrl *string `json:"apexUrl,omitempty"` + DatabaseTransformsUrl *string `json:"databaseTransformsUrl,omitempty"` + GraphStudioUrl *string `json:"graphStudioUrl,omitempty"` + MachineLearningNotebookUrl *string `json:"machineLearningNotebookUrl,omitempty"` + MongoDbUrl *string `json:"mongoDbUrl,omitempty"` + OrdsUrl *string `json:"ordsUrl,omitempty"` + SqlDevWebUrl *string `json:"sqlDevWebUrl,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_customercontact.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_customercontact.go new file mode 100644 index 00000000000..f0cb840d637 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_customercontact.go @@ -0,0 +1,8 @@ +package autonomousdatabases + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomerContact struct { + Email string `json:"email"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_dayofweek.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_dayofweek.go new file mode 100644 index 00000000000..f3a881a70d0 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_dayofweek.go @@ -0,0 +1,8 @@ +package autonomousdatabases + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DayOfWeek struct { + Name DayOfWeekName `json:"name"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_dayofweekupdate.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_dayofweekupdate.go new file mode 100644 index 00000000000..3a2293955d2 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_dayofweekupdate.go @@ -0,0 +1,8 @@ +package autonomousdatabases + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DayOfWeekUpdate struct { + Name *DayOfWeekName `json:"name,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_generateautonomousdatabasewalletdetails.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_generateautonomousdatabasewalletdetails.go new file mode 100644 index 00000000000..1ac191ea68d --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_generateautonomousdatabasewalletdetails.go @@ -0,0 +1,10 @@ +package autonomousdatabases + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GenerateAutonomousDatabaseWalletDetails struct { + GenerateType *GenerateType `json:"generateType,omitempty"` + IsRegional *bool `json:"isRegional,omitempty"` + Password string `json:"password"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_longtermbackupscheduledetails.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_longtermbackupscheduledetails.go new file mode 100644 index 00000000000..3219641f573 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_longtermbackupscheduledetails.go @@ -0,0 +1,29 @@ +package autonomousdatabases + +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 LongTermBackUpScheduleDetails struct { + IsDisabled *bool `json:"isDisabled,omitempty"` + RepeatCadence *RepeatCadenceType `json:"repeatCadence,omitempty"` + RetentionPeriodInDays *int64 `json:"retentionPeriodInDays,omitempty"` + TimeOfBackup *string `json:"timeOfBackup,omitempty"` +} + +func (o *LongTermBackUpScheduleDetails) GetTimeOfBackupAsTime() (*time.Time, error) { + if o.TimeOfBackup == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeOfBackup, "2006-01-02T15:04:05Z07:00") +} + +func (o *LongTermBackUpScheduleDetails) SetTimeOfBackupAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeOfBackup = &formatted +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_peerdbdetails.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_peerdbdetails.go new file mode 100644 index 00000000000..8d223d8e505 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_peerdbdetails.go @@ -0,0 +1,8 @@ +package autonomousdatabases + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PeerDbDetails struct { + PeerDbId *string `json:"peerDbId,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_profiletype.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_profiletype.go new file mode 100644 index 00000000000..23033b333c9 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_profiletype.go @@ -0,0 +1,16 @@ +package autonomousdatabases + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProfileType struct { + ConsumerGroup *ConsumerGroup `json:"consumerGroup,omitempty"` + DisplayName string `json:"displayName"` + HostFormat HostFormatType `json:"hostFormat"` + IsRegional *bool `json:"isRegional,omitempty"` + Protocol ProtocolType `json:"protocol"` + SessionMode SessionModeType `json:"sessionMode"` + SyntaxFormat SyntaxFormatType `json:"syntaxFormat"` + TlsAuthentication *TlsAuthenticationType `json:"tlsAuthentication,omitempty"` + Value string `json:"value"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_restoreautonomousdatabasedetails.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_restoreautonomousdatabasedetails.go new file mode 100644 index 00000000000..62563f3bd97 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_restoreautonomousdatabasedetails.go @@ -0,0 +1,23 @@ +package autonomousdatabases + +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 RestoreAutonomousDatabaseDetails struct { + Timestamp string `json:"timestamp"` +} + +func (o *RestoreAutonomousDatabaseDetails) GetTimestampAsTime() (*time.Time, error) { + return dates.ParseAsFormat(&o.Timestamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *RestoreAutonomousDatabaseDetails) SetTimestampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Timestamp = formatted +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_scheduledoperationstype.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_scheduledoperationstype.go new file mode 100644 index 00000000000..c8ddec8547e --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_scheduledoperationstype.go @@ -0,0 +1,10 @@ +package autonomousdatabases + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScheduledOperationsType struct { + DayOfWeek DayOfWeek `json:"dayOfWeek"` + ScheduledStartTime *string `json:"scheduledStartTime,omitempty"` + ScheduledStopTime *string `json:"scheduledStopTime,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_scheduledoperationstypeupdate.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_scheduledoperationstypeupdate.go new file mode 100644 index 00000000000..d0ce963fa63 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/model_scheduledoperationstypeupdate.go @@ -0,0 +1,10 @@ +package autonomousdatabases + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScheduledOperationsTypeUpdate struct { + DayOfWeek *DayOfWeekUpdate `json:"dayOfWeek,omitempty"` + ScheduledStartTime *string `json:"scheduledStartTime,omitempty"` + ScheduledStopTime *string `json:"scheduledStopTime,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/predicates.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/predicates.go new file mode 100644 index 00000000000..30749532d68 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/predicates.go @@ -0,0 +1,32 @@ +package autonomousdatabases + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutonomousDatabaseOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p AutonomousDatabaseOperationPredicate) Matches(input AutonomousDatabase) 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/oracledatabase/2024-06-01/autonomousdatabases/version.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/version.go new file mode 100644 index 00000000000..bb55880a3d8 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabases/version.go @@ -0,0 +1,12 @@ +package autonomousdatabases + +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-06-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/autonomousdatabases/%s", defaultApiVersion) +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/README.md b/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/README.md new file mode 100644 index 00000000000..0dab6f05679 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions` Documentation + +The `autonomousdatabaseversions` SDK allows for interaction with the Azure Resource Manager Service `oracledatabase` (API Version `2024-06-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/oracledatabase/2024-06-01/autonomousdatabaseversions" +``` + + +### Client Initialization + +```go +client := autonomousdatabaseversions.NewAutonomousDatabaseVersionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AutonomousDatabaseVersionsClient.Get` + +```go +ctx := context.TODO() +id := autonomousdatabaseversions.NewAutonomousDbVersionID("12345678-1234-9876-4563-123456789012", "locationValue", "autonomousDbVersionValue") + +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: `AutonomousDatabaseVersionsClient.ListByLocation` + +```go +ctx := context.TODO() +id := autonomousdatabaseversions.NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + +// alternatively `client.ListByLocation(ctx, id)` can be used to do batched pagination +items, err := client.ListByLocationComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/client.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/client.go new file mode 100644 index 00000000000..a456628fcc0 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/client.go @@ -0,0 +1,26 @@ +package autonomousdatabaseversions + +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 AutonomousDatabaseVersionsClient struct { + Client *resourcemanager.Client +} + +func NewAutonomousDatabaseVersionsClientWithBaseURI(sdkApi sdkEnv.Api) (*AutonomousDatabaseVersionsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "autonomousdatabaseversions", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AutonomousDatabaseVersionsClient: %+v", err) + } + + return &AutonomousDatabaseVersionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/constants.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/constants.go new file mode 100644 index 00000000000..f4d7200f6ed --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/constants.go @@ -0,0 +1,57 @@ +package autonomousdatabaseversions + +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 WorkloadType string + +const ( + WorkloadTypeAJD WorkloadType = "AJD" + WorkloadTypeAPEX WorkloadType = "APEX" + WorkloadTypeDW WorkloadType = "DW" + WorkloadTypeOLTP WorkloadType = "OLTP" +) + +func PossibleValuesForWorkloadType() []string { + return []string{ + string(WorkloadTypeAJD), + string(WorkloadTypeAPEX), + string(WorkloadTypeDW), + string(WorkloadTypeOLTP), + } +} + +func (s *WorkloadType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkloadType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkloadType(input string) (*WorkloadType, error) { + vals := map[string]WorkloadType{ + "ajd": WorkloadTypeAJD, + "apex": WorkloadTypeAPEX, + "dw": WorkloadTypeDW, + "oltp": WorkloadTypeOLTP, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkloadType(input) + return &out, nil +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/id_autonomousdbversion.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/id_autonomousdbversion.go new file mode 100644 index 00000000000..ea983d4be6e --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/id_autonomousdbversion.go @@ -0,0 +1,130 @@ +package autonomousdatabaseversions + +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(&AutonomousDbVersionId{}) +} + +var _ resourceids.ResourceId = &AutonomousDbVersionId{} + +// AutonomousDbVersionId is a struct representing the Resource ID for a Autonomous Db Version +type AutonomousDbVersionId struct { + SubscriptionId string + LocationName string + AutonomousDbVersionName string +} + +// NewAutonomousDbVersionID returns a new AutonomousDbVersionId struct +func NewAutonomousDbVersionID(subscriptionId string, locationName string, autonomousDbVersionName string) AutonomousDbVersionId { + return AutonomousDbVersionId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + AutonomousDbVersionName: autonomousDbVersionName, + } +} + +// ParseAutonomousDbVersionID parses 'input' into a AutonomousDbVersionId +func ParseAutonomousDbVersionID(input string) (*AutonomousDbVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&AutonomousDbVersionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AutonomousDbVersionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAutonomousDbVersionIDInsensitively parses 'input' case-insensitively into a AutonomousDbVersionId +// note: this method should only be used for API response data and not user input +func ParseAutonomousDbVersionIDInsensitively(input string) (*AutonomousDbVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&AutonomousDbVersionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AutonomousDbVersionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AutonomousDbVersionId) 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) + } + + if id.AutonomousDbVersionName, ok = input.Parsed["autonomousDbVersionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "autonomousDbVersionName", input) + } + + return nil +} + +// ValidateAutonomousDbVersionID checks that 'input' can be parsed as a Autonomous Db Version ID +func ValidateAutonomousDbVersionID(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 := ParseAutonomousDbVersionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Autonomous Db Version ID +func (id AutonomousDbVersionId) ID() string { + fmtString := "/subscriptions/%s/providers/Oracle.Database/locations/%s/autonomousDbVersions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName, id.AutonomousDbVersionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Autonomous Db Version ID +func (id AutonomousDbVersionId) 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("staticOracleDatabase", "Oracle.Database", "Oracle.Database"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationValue"), + resourceids.StaticSegment("staticAutonomousDbVersions", "autonomousDbVersions", "autonomousDbVersions"), + resourceids.UserSpecifiedSegment("autonomousDbVersionName", "autonomousDbVersionValue"), + } +} + +// String returns a human-readable description of this Autonomous Db Version ID +func (id AutonomousDbVersionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + fmt.Sprintf("Autonomous Db Version Name: %q", id.AutonomousDbVersionName), + } + return fmt.Sprintf("Autonomous Db Version (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/id_autonomousdbversion_test.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/id_autonomousdbversion_test.go new file mode 100644 index 00000000000..2c09ac11d11 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/id_autonomousdbversion_test.go @@ -0,0 +1,282 @@ +package autonomousdatabaseversions + +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 = &AutonomousDbVersionId{} + +func TestNewAutonomousDbVersionID(t *testing.T) { + id := NewAutonomousDbVersionID("12345678-1234-9876-4563-123456789012", "locationValue", "autonomousDbVersionValue") + + 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") + } + + if id.AutonomousDbVersionName != "autonomousDbVersionValue" { + t.Fatalf("Expected %q but got %q for Segment 'AutonomousDbVersionName'", id.AutonomousDbVersionName, "autonomousDbVersionValue") + } +} + +func TestFormatAutonomousDbVersionID(t *testing.T) { + actual := NewAutonomousDbVersionID("12345678-1234-9876-4563-123456789012", "locationValue", "autonomousDbVersionValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/autonomousDbVersions/autonomousDbVersionValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAutonomousDbVersionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AutonomousDbVersionId + }{ + { + // 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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/autonomousDbVersions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/autonomousDbVersions/autonomousDbVersionValue", + Expected: &AutonomousDbVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + AutonomousDbVersionName: "autonomousDbVersionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/autonomousDbVersions/autonomousDbVersionValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAutonomousDbVersionID(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) + } + + if actual.AutonomousDbVersionName != v.Expected.AutonomousDbVersionName { + t.Fatalf("Expected %q but got %q for AutonomousDbVersionName", v.Expected.AutonomousDbVersionName, actual.AutonomousDbVersionName) + } + + } +} + +func TestParseAutonomousDbVersionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AutonomousDbVersionId + }{ + { + // 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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs/lOcAtIoNvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/autonomousDbVersions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs/lOcAtIoNvAlUe/aUtOnOmOuSdBvErSiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/autonomousDbVersions/autonomousDbVersionValue", + Expected: &AutonomousDbVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + AutonomousDbVersionName: "autonomousDbVersionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/autonomousDbVersions/autonomousDbVersionValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs/lOcAtIoNvAlUe/aUtOnOmOuSdBvErSiOnS/aUtOnOmOuSdBvErSiOnVaLuE", + Expected: &AutonomousDbVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNvAlUe", + AutonomousDbVersionName: "aUtOnOmOuSdBvErSiOnVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs/lOcAtIoNvAlUe/aUtOnOmOuSdBvErSiOnS/aUtOnOmOuSdBvErSiOnVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAutonomousDbVersionIDInsensitively(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) + } + + if actual.AutonomousDbVersionName != v.Expected.AutonomousDbVersionName { + t.Fatalf("Expected %q but got %q for AutonomousDbVersionName", v.Expected.AutonomousDbVersionName, actual.AutonomousDbVersionName) + } + + } +} + +func TestSegmentsForAutonomousDbVersionId(t *testing.T) { + segments := AutonomousDbVersionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AutonomousDbVersionId 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/oracledatabase/2024-06-01/autonomousdatabaseversions/id_location.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/id_location.go new file mode 100644 index 00000000000..9f10f98bb92 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/id_location.go @@ -0,0 +1,121 @@ +package autonomousdatabaseversions + +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/Oracle.Database/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("staticOracleDatabase", "Oracle.Database", "Oracle.Database"), + 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/oracledatabase/2024-06-01/autonomousdatabaseversions/id_location_test.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/id_location_test.go new file mode 100644 index 00000000000..ccd72c69d86 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/id_location_test.go @@ -0,0 +1,237 @@ +package autonomousdatabaseversions + +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/Oracle.Database/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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/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/Oracle.Database/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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/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/Oracle.Database/locations/locationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/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/oRaClE.DaTaBaSe/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/oracledatabase/2024-06-01/autonomousdatabaseversions/method_get.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/method_get.go new file mode 100644 index 00000000000..1e73740c6d8 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/method_get.go @@ -0,0 +1,54 @@ +package autonomousdatabaseversions + +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 *AutonomousDbVersion +} + +// Get ... +func (c AutonomousDatabaseVersionsClient) Get(ctx context.Context, id AutonomousDbVersionId) (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 AutonomousDbVersion + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/method_listbylocation.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/method_listbylocation.go new file mode 100644 index 00000000000..3568f7d2e00 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/method_listbylocation.go @@ -0,0 +1,105 @@ +package autonomousdatabaseversions + +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 ListByLocationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AutonomousDbVersion +} + +type ListByLocationCompleteResult struct { + LatestHttpResponse *http.Response + Items []AutonomousDbVersion +} + +type ListByLocationCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByLocationCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByLocation ... +func (c AutonomousDatabaseVersionsClient) ListByLocation(ctx context.Context, id LocationId) (result ListByLocationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByLocationCustomPager{}, + Path: fmt.Sprintf("%s/autonomousDbVersions", 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 *[]AutonomousDbVersion `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByLocationComplete retrieves all the results into a single object +func (c AutonomousDatabaseVersionsClient) ListByLocationComplete(ctx context.Context, id LocationId) (ListByLocationCompleteResult, error) { + return c.ListByLocationCompleteMatchingPredicate(ctx, id, AutonomousDbVersionOperationPredicate{}) +} + +// ListByLocationCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AutonomousDatabaseVersionsClient) ListByLocationCompleteMatchingPredicate(ctx context.Context, id LocationId, predicate AutonomousDbVersionOperationPredicate) (result ListByLocationCompleteResult, err error) { + items := make([]AutonomousDbVersion, 0) + + resp, err := c.ListByLocation(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByLocationCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/model_autonomousdbversion.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/model_autonomousdbversion.go new file mode 100644 index 00000000000..d637e754ddf --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/model_autonomousdbversion.go @@ -0,0 +1,16 @@ +package autonomousdatabaseversions + +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 AutonomousDbVersion struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AutonomousDbVersionProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/model_autonomousdbversionproperties.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/model_autonomousdbversionproperties.go new file mode 100644 index 00000000000..0a7cad672e7 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/model_autonomousdbversionproperties.go @@ -0,0 +1,13 @@ +package autonomousdatabaseversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutonomousDbVersionProperties struct { + DbWorkload *WorkloadType `json:"dbWorkload,omitempty"` + IsDefaultForFree *bool `json:"isDefaultForFree,omitempty"` + IsDefaultForPaid *bool `json:"isDefaultForPaid,omitempty"` + IsFreeTierEnabled *bool `json:"isFreeTierEnabled,omitempty"` + IsPaidEnabled *bool `json:"isPaidEnabled,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/predicates.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/predicates.go new file mode 100644 index 00000000000..87d67558b5f --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/predicates.go @@ -0,0 +1,27 @@ +package autonomousdatabaseversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutonomousDbVersionOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p AutonomousDbVersionOperationPredicate) Matches(input AutonomousDbVersion) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/version.go b/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/version.go new file mode 100644 index 00000000000..b4c1d6d8dfe --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions/version.go @@ -0,0 +1,12 @@ +package autonomousdatabaseversions + +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-06-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/autonomousdatabaseversions/%s", defaultApiVersion) +} diff --git a/resource-manager/oracledatabase/2024-06-01/client.go b/resource-manager/oracledatabase/2024-06-01/client.go new file mode 100644 index 00000000000..779de7918c4 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/client.go @@ -0,0 +1,163 @@ +package v2024_06_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/oracledatabase/2024-06-01/autonomousdatabasebackups" + "github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/autonomousdatabasecharactersets" + "github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/autonomousdatabasenationalcharactersets" + "github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/autonomousdatabases" + "github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/autonomousdatabaseversions" + "github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures" + "github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/cloudvmclusters" + "github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/dbnodes" + "github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/dbservers" + "github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/dbsystemshapes" + "github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/dnsprivateviews" + "github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/dnsprivatezones" + "github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/giversions" + "github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions" + "github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/systemversions" + "github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/virtualnetworkaddresses" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + AutonomousDatabaseBackups *autonomousdatabasebackups.AutonomousDatabaseBackupsClient + AutonomousDatabaseCharacterSets *autonomousdatabasecharactersets.AutonomousDatabaseCharacterSetsClient + AutonomousDatabaseNationalCharacterSets *autonomousdatabasenationalcharactersets.AutonomousDatabaseNationalCharacterSetsClient + AutonomousDatabaseVersions *autonomousdatabaseversions.AutonomousDatabaseVersionsClient + AutonomousDatabases *autonomousdatabases.AutonomousDatabasesClient + CloudExadataInfrastructures *cloudexadatainfrastructures.CloudExadataInfrastructuresClient + CloudVMClusters *cloudvmclusters.CloudVMClustersClient + DbNodes *dbnodes.DbNodesClient + DbServers *dbservers.DbServersClient + DbSystemShapes *dbsystemshapes.DbSystemShapesClient + DnsPrivateViews *dnsprivateviews.DnsPrivateViewsClient + DnsPrivateZones *dnsprivatezones.DnsPrivateZonesClient + GiVersions *giversions.GiVersionsClient + OracleSubscriptions *oraclesubscriptions.OracleSubscriptionsClient + SystemVersions *systemversions.SystemVersionsClient + VirtualNetworkAddresses *virtualnetworkaddresses.VirtualNetworkAddressesClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + autonomousDatabaseBackupsClient, err := autonomousdatabasebackups.NewAutonomousDatabaseBackupsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AutonomousDatabaseBackups client: %+v", err) + } + configureFunc(autonomousDatabaseBackupsClient.Client) + + autonomousDatabaseCharacterSetsClient, err := autonomousdatabasecharactersets.NewAutonomousDatabaseCharacterSetsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AutonomousDatabaseCharacterSets client: %+v", err) + } + configureFunc(autonomousDatabaseCharacterSetsClient.Client) + + autonomousDatabaseNationalCharacterSetsClient, err := autonomousdatabasenationalcharactersets.NewAutonomousDatabaseNationalCharacterSetsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AutonomousDatabaseNationalCharacterSets client: %+v", err) + } + configureFunc(autonomousDatabaseNationalCharacterSetsClient.Client) + + autonomousDatabaseVersionsClient, err := autonomousdatabaseversions.NewAutonomousDatabaseVersionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AutonomousDatabaseVersions client: %+v", err) + } + configureFunc(autonomousDatabaseVersionsClient.Client) + + autonomousDatabasesClient, err := autonomousdatabases.NewAutonomousDatabasesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AutonomousDatabases client: %+v", err) + } + configureFunc(autonomousDatabasesClient.Client) + + cloudExadataInfrastructuresClient, err := cloudexadatainfrastructures.NewCloudExadataInfrastructuresClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building CloudExadataInfrastructures client: %+v", err) + } + configureFunc(cloudExadataInfrastructuresClient.Client) + + cloudVMClustersClient, err := cloudvmclusters.NewCloudVMClustersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building CloudVMClusters client: %+v", err) + } + configureFunc(cloudVMClustersClient.Client) + + dbNodesClient, err := dbnodes.NewDbNodesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building DbNodes client: %+v", err) + } + configureFunc(dbNodesClient.Client) + + dbServersClient, err := dbservers.NewDbServersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building DbServers client: %+v", err) + } + configureFunc(dbServersClient.Client) + + dbSystemShapesClient, err := dbsystemshapes.NewDbSystemShapesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building DbSystemShapes client: %+v", err) + } + configureFunc(dbSystemShapesClient.Client) + + dnsPrivateViewsClient, err := dnsprivateviews.NewDnsPrivateViewsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building DnsPrivateViews client: %+v", err) + } + configureFunc(dnsPrivateViewsClient.Client) + + dnsPrivateZonesClient, err := dnsprivatezones.NewDnsPrivateZonesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building DnsPrivateZones client: %+v", err) + } + configureFunc(dnsPrivateZonesClient.Client) + + giVersionsClient, err := giversions.NewGiVersionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building GiVersions client: %+v", err) + } + configureFunc(giVersionsClient.Client) + + oracleSubscriptionsClient, err := oraclesubscriptions.NewOracleSubscriptionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building OracleSubscriptions client: %+v", err) + } + configureFunc(oracleSubscriptionsClient.Client) + + systemVersionsClient, err := systemversions.NewSystemVersionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SystemVersions client: %+v", err) + } + configureFunc(systemVersionsClient.Client) + + virtualNetworkAddressesClient, err := virtualnetworkaddresses.NewVirtualNetworkAddressesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building VirtualNetworkAddresses client: %+v", err) + } + configureFunc(virtualNetworkAddressesClient.Client) + + return &Client{ + AutonomousDatabaseBackups: autonomousDatabaseBackupsClient, + AutonomousDatabaseCharacterSets: autonomousDatabaseCharacterSetsClient, + AutonomousDatabaseNationalCharacterSets: autonomousDatabaseNationalCharacterSetsClient, + AutonomousDatabaseVersions: autonomousDatabaseVersionsClient, + AutonomousDatabases: autonomousDatabasesClient, + CloudExadataInfrastructures: cloudExadataInfrastructuresClient, + CloudVMClusters: cloudVMClustersClient, + DbNodes: dbNodesClient, + DbServers: dbServersClient, + DbSystemShapes: dbSystemShapesClient, + DnsPrivateViews: dnsPrivateViewsClient, + DnsPrivateZones: dnsPrivateZonesClient, + GiVersions: giVersionsClient, + OracleSubscriptions: oracleSubscriptionsClient, + SystemVersions: systemVersionsClient, + VirtualNetworkAddresses: virtualNetworkAddressesClient, + }, nil +} diff --git a/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/README.md b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/README.md new file mode 100644 index 00000000000..dcf8b7af55a --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/README.md @@ -0,0 +1,129 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures` Documentation + +The `cloudexadatainfrastructures` SDK allows for interaction with the Azure Resource Manager Service `oracledatabase` (API Version `2024-06-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/oracledatabase/2024-06-01/cloudexadatainfrastructures" +``` + + +### Client Initialization + +```go +client := cloudexadatainfrastructures.NewCloudExadataInfrastructuresClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CloudExadataInfrastructuresClient.AddStorageCapacity` + +```go +ctx := context.TODO() +id := cloudexadatainfrastructures.NewCloudExadataInfrastructureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudExadataInfrastructureValue") + +if err := client.AddStorageCapacityThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CloudExadataInfrastructuresClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := cloudexadatainfrastructures.NewCloudExadataInfrastructureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudExadataInfrastructureValue") + +payload := cloudexadatainfrastructures.CloudExadataInfrastructure{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CloudExadataInfrastructuresClient.Delete` + +```go +ctx := context.TODO() +id := cloudexadatainfrastructures.NewCloudExadataInfrastructureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudExadataInfrastructureValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CloudExadataInfrastructuresClient.Get` + +```go +ctx := context.TODO() +id := cloudexadatainfrastructures.NewCloudExadataInfrastructureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudExadataInfrastructureValue") + +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: `CloudExadataInfrastructuresClient.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: `CloudExadataInfrastructuresClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `CloudExadataInfrastructuresClient.Update` + +```go +ctx := context.TODO() +id := cloudexadatainfrastructures.NewCloudExadataInfrastructureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudExadataInfrastructureValue") + +payload := cloudexadatainfrastructures.CloudExadataInfrastructureUpdate{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/client.go b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/client.go new file mode 100644 index 00000000000..8c55d2b0aa5 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/client.go @@ -0,0 +1,26 @@ +package cloudexadatainfrastructures + +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 CloudExadataInfrastructuresClient struct { + Client *resourcemanager.Client +} + +func NewCloudExadataInfrastructuresClientWithBaseURI(sdkApi sdkEnv.Api) (*CloudExadataInfrastructuresClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "cloudexadatainfrastructures", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CloudExadataInfrastructuresClient: %+v", err) + } + + return &CloudExadataInfrastructuresClient{ + Client: client, + }, nil +} diff --git a/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/constants.go b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/constants.go new file mode 100644 index 00000000000..1baad8c6fdd --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/constants.go @@ -0,0 +1,322 @@ +package cloudexadatainfrastructures + +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 AzureResourceProvisioningState string + +const ( + AzureResourceProvisioningStateCanceled AzureResourceProvisioningState = "Canceled" + AzureResourceProvisioningStateFailed AzureResourceProvisioningState = "Failed" + AzureResourceProvisioningStateProvisioning AzureResourceProvisioningState = "Provisioning" + AzureResourceProvisioningStateSucceeded AzureResourceProvisioningState = "Succeeded" +) + +func PossibleValuesForAzureResourceProvisioningState() []string { + return []string{ + string(AzureResourceProvisioningStateCanceled), + string(AzureResourceProvisioningStateFailed), + string(AzureResourceProvisioningStateProvisioning), + string(AzureResourceProvisioningStateSucceeded), + } +} + +func (s *AzureResourceProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureResourceProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureResourceProvisioningState(input string) (*AzureResourceProvisioningState, error) { + vals := map[string]AzureResourceProvisioningState{ + "canceled": AzureResourceProvisioningStateCanceled, + "failed": AzureResourceProvisioningStateFailed, + "provisioning": AzureResourceProvisioningStateProvisioning, + "succeeded": AzureResourceProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureResourceProvisioningState(input) + return &out, nil +} + +type CloudExadataInfrastructureLifecycleState string + +const ( + CloudExadataInfrastructureLifecycleStateAvailable CloudExadataInfrastructureLifecycleState = "Available" + CloudExadataInfrastructureLifecycleStateFailed CloudExadataInfrastructureLifecycleState = "Failed" + CloudExadataInfrastructureLifecycleStateMaintenanceInProgress CloudExadataInfrastructureLifecycleState = "MaintenanceInProgress" + CloudExadataInfrastructureLifecycleStateProvisioning CloudExadataInfrastructureLifecycleState = "Provisioning" + CloudExadataInfrastructureLifecycleStateTerminated CloudExadataInfrastructureLifecycleState = "Terminated" + CloudExadataInfrastructureLifecycleStateTerminating CloudExadataInfrastructureLifecycleState = "Terminating" + CloudExadataInfrastructureLifecycleStateUpdating CloudExadataInfrastructureLifecycleState = "Updating" +) + +func PossibleValuesForCloudExadataInfrastructureLifecycleState() []string { + return []string{ + string(CloudExadataInfrastructureLifecycleStateAvailable), + string(CloudExadataInfrastructureLifecycleStateFailed), + string(CloudExadataInfrastructureLifecycleStateMaintenanceInProgress), + string(CloudExadataInfrastructureLifecycleStateProvisioning), + string(CloudExadataInfrastructureLifecycleStateTerminated), + string(CloudExadataInfrastructureLifecycleStateTerminating), + string(CloudExadataInfrastructureLifecycleStateUpdating), + } +} + +func (s *CloudExadataInfrastructureLifecycleState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCloudExadataInfrastructureLifecycleState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCloudExadataInfrastructureLifecycleState(input string) (*CloudExadataInfrastructureLifecycleState, error) { + vals := map[string]CloudExadataInfrastructureLifecycleState{ + "available": CloudExadataInfrastructureLifecycleStateAvailable, + "failed": CloudExadataInfrastructureLifecycleStateFailed, + "maintenanceinprogress": CloudExadataInfrastructureLifecycleStateMaintenanceInProgress, + "provisioning": CloudExadataInfrastructureLifecycleStateProvisioning, + "terminated": CloudExadataInfrastructureLifecycleStateTerminated, + "terminating": CloudExadataInfrastructureLifecycleStateTerminating, + "updating": CloudExadataInfrastructureLifecycleStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CloudExadataInfrastructureLifecycleState(input) + return &out, nil +} + +type DayOfWeekName string + +const ( + DayOfWeekNameFriday DayOfWeekName = "Friday" + DayOfWeekNameMonday DayOfWeekName = "Monday" + DayOfWeekNameSaturday DayOfWeekName = "Saturday" + DayOfWeekNameSunday DayOfWeekName = "Sunday" + DayOfWeekNameThursday DayOfWeekName = "Thursday" + DayOfWeekNameTuesday DayOfWeekName = "Tuesday" + DayOfWeekNameWednesday DayOfWeekName = "Wednesday" +) + +func PossibleValuesForDayOfWeekName() []string { + return []string{ + string(DayOfWeekNameFriday), + string(DayOfWeekNameMonday), + string(DayOfWeekNameSaturday), + string(DayOfWeekNameSunday), + string(DayOfWeekNameThursday), + string(DayOfWeekNameTuesday), + string(DayOfWeekNameWednesday), + } +} + +func (s *DayOfWeekName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDayOfWeekName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDayOfWeekName(input string) (*DayOfWeekName, error) { + vals := map[string]DayOfWeekName{ + "friday": DayOfWeekNameFriday, + "monday": DayOfWeekNameMonday, + "saturday": DayOfWeekNameSaturday, + "sunday": DayOfWeekNameSunday, + "thursday": DayOfWeekNameThursday, + "tuesday": DayOfWeekNameTuesday, + "wednesday": DayOfWeekNameWednesday, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DayOfWeekName(input) + return &out, nil +} + +type MonthName string + +const ( + MonthNameApril MonthName = "April" + MonthNameAugust MonthName = "August" + MonthNameDecember MonthName = "December" + MonthNameFebruary MonthName = "February" + MonthNameJanuary MonthName = "January" + MonthNameJuly MonthName = "July" + MonthNameJune MonthName = "June" + MonthNameMarch MonthName = "March" + MonthNameMay MonthName = "May" + MonthNameNovember MonthName = "November" + MonthNameOctober MonthName = "October" + MonthNameSeptember MonthName = "September" +) + +func PossibleValuesForMonthName() []string { + return []string{ + string(MonthNameApril), + string(MonthNameAugust), + string(MonthNameDecember), + string(MonthNameFebruary), + string(MonthNameJanuary), + string(MonthNameJuly), + string(MonthNameJune), + string(MonthNameMarch), + string(MonthNameMay), + string(MonthNameNovember), + string(MonthNameOctober), + string(MonthNameSeptember), + } +} + +func (s *MonthName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMonthName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMonthName(input string) (*MonthName, error) { + vals := map[string]MonthName{ + "april": MonthNameApril, + "august": MonthNameAugust, + "december": MonthNameDecember, + "february": MonthNameFebruary, + "january": MonthNameJanuary, + "july": MonthNameJuly, + "june": MonthNameJune, + "march": MonthNameMarch, + "may": MonthNameMay, + "november": MonthNameNovember, + "october": MonthNameOctober, + "september": MonthNameSeptember, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MonthName(input) + return &out, nil +} + +type PatchingMode string + +const ( + PatchingModeNonRolling PatchingMode = "NonRolling" + PatchingModeRolling PatchingMode = "Rolling" +) + +func PossibleValuesForPatchingMode() []string { + return []string{ + string(PatchingModeNonRolling), + string(PatchingModeRolling), + } +} + +func (s *PatchingMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePatchingMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePatchingMode(input string) (*PatchingMode, error) { + vals := map[string]PatchingMode{ + "nonrolling": PatchingModeNonRolling, + "rolling": PatchingModeRolling, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PatchingMode(input) + return &out, nil +} + +type Preference string + +const ( + PreferenceCustomPreference Preference = "CustomPreference" + PreferenceNoPreference Preference = "NoPreference" +) + +func PossibleValuesForPreference() []string { + return []string{ + string(PreferenceCustomPreference), + string(PreferenceNoPreference), + } +} + +func (s *Preference) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePreference(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePreference(input string) (*Preference, error) { + vals := map[string]Preference{ + "custompreference": PreferenceCustomPreference, + "nopreference": PreferenceNoPreference, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Preference(input) + return &out, nil +} diff --git a/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/id_cloudexadatainfrastructure.go b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/id_cloudexadatainfrastructure.go new file mode 100644 index 00000000000..64edbb20ca1 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/id_cloudexadatainfrastructure.go @@ -0,0 +1,130 @@ +package cloudexadatainfrastructures + +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(&CloudExadataInfrastructureId{}) +} + +var _ resourceids.ResourceId = &CloudExadataInfrastructureId{} + +// CloudExadataInfrastructureId is a struct representing the Resource ID for a Cloud Exadata Infrastructure +type CloudExadataInfrastructureId struct { + SubscriptionId string + ResourceGroupName string + CloudExadataInfrastructureName string +} + +// NewCloudExadataInfrastructureID returns a new CloudExadataInfrastructureId struct +func NewCloudExadataInfrastructureID(subscriptionId string, resourceGroupName string, cloudExadataInfrastructureName string) CloudExadataInfrastructureId { + return CloudExadataInfrastructureId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CloudExadataInfrastructureName: cloudExadataInfrastructureName, + } +} + +// ParseCloudExadataInfrastructureID parses 'input' into a CloudExadataInfrastructureId +func ParseCloudExadataInfrastructureID(input string) (*CloudExadataInfrastructureId, error) { + parser := resourceids.NewParserFromResourceIdType(&CloudExadataInfrastructureId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CloudExadataInfrastructureId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCloudExadataInfrastructureIDInsensitively parses 'input' case-insensitively into a CloudExadataInfrastructureId +// note: this method should only be used for API response data and not user input +func ParseCloudExadataInfrastructureIDInsensitively(input string) (*CloudExadataInfrastructureId, error) { + parser := resourceids.NewParserFromResourceIdType(&CloudExadataInfrastructureId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CloudExadataInfrastructureId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CloudExadataInfrastructureId) 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.CloudExadataInfrastructureName, ok = input.Parsed["cloudExadataInfrastructureName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "cloudExadataInfrastructureName", input) + } + + return nil +} + +// ValidateCloudExadataInfrastructureID checks that 'input' can be parsed as a Cloud Exadata Infrastructure ID +func ValidateCloudExadataInfrastructureID(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 := ParseCloudExadataInfrastructureID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Cloud Exadata Infrastructure ID +func (id CloudExadataInfrastructureId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Oracle.Database/cloudExadataInfrastructures/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CloudExadataInfrastructureName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Cloud Exadata Infrastructure ID +func (id CloudExadataInfrastructureId) 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("staticOracleDatabase", "Oracle.Database", "Oracle.Database"), + resourceids.StaticSegment("staticCloudExadataInfrastructures", "cloudExadataInfrastructures", "cloudExadataInfrastructures"), + resourceids.UserSpecifiedSegment("cloudExadataInfrastructureName", "cloudExadataInfrastructureValue"), + } +} + +// String returns a human-readable description of this Cloud Exadata Infrastructure ID +func (id CloudExadataInfrastructureId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cloud Exadata Infrastructure Name: %q", id.CloudExadataInfrastructureName), + } + return fmt.Sprintf("Cloud Exadata Infrastructure (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/id_cloudexadatainfrastructure_test.go b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/id_cloudexadatainfrastructure_test.go new file mode 100644 index 00000000000..d87bbaf41c2 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/id_cloudexadatainfrastructure_test.go @@ -0,0 +1,282 @@ +package cloudexadatainfrastructures + +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 = &CloudExadataInfrastructureId{} + +func TestNewCloudExadataInfrastructureID(t *testing.T) { + id := NewCloudExadataInfrastructureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudExadataInfrastructureValue") + + 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.CloudExadataInfrastructureName != "cloudExadataInfrastructureValue" { + t.Fatalf("Expected %q but got %q for Segment 'CloudExadataInfrastructureName'", id.CloudExadataInfrastructureName, "cloudExadataInfrastructureValue") + } +} + +func TestFormatCloudExadataInfrastructureID(t *testing.T) { + actual := NewCloudExadataInfrastructureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudExadataInfrastructureValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudExadataInfrastructures/cloudExadataInfrastructureValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCloudExadataInfrastructureID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CloudExadataInfrastructureId + }{ + { + // 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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudExadataInfrastructures", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudExadataInfrastructures/cloudExadataInfrastructureValue", + Expected: &CloudExadataInfrastructureId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudExadataInfrastructureName: "cloudExadataInfrastructureValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudExadataInfrastructures/cloudExadataInfrastructureValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCloudExadataInfrastructureID(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.CloudExadataInfrastructureName != v.Expected.CloudExadataInfrastructureName { + t.Fatalf("Expected %q but got %q for CloudExadataInfrastructureName", v.Expected.CloudExadataInfrastructureName, actual.CloudExadataInfrastructureName) + } + + } +} + +func TestParseCloudExadataInfrastructureIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CloudExadataInfrastructureId + }{ + { + // 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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudExadataInfrastructures", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe/cLoUdExAdAtAiNfRaStRuCtUrEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudExadataInfrastructures/cloudExadataInfrastructureValue", + Expected: &CloudExadataInfrastructureId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudExadataInfrastructureName: "cloudExadataInfrastructureValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudExadataInfrastructures/cloudExadataInfrastructureValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe/cLoUdExAdAtAiNfRaStRuCtUrEs/cLoUdExAdAtAiNfRaStRuCtUrEvAlUe", + Expected: &CloudExadataInfrastructureId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CloudExadataInfrastructureName: "cLoUdExAdAtAiNfRaStRuCtUrEvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe/cLoUdExAdAtAiNfRaStRuCtUrEs/cLoUdExAdAtAiNfRaStRuCtUrEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCloudExadataInfrastructureIDInsensitively(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.CloudExadataInfrastructureName != v.Expected.CloudExadataInfrastructureName { + t.Fatalf("Expected %q but got %q for CloudExadataInfrastructureName", v.Expected.CloudExadataInfrastructureName, actual.CloudExadataInfrastructureName) + } + + } +} + +func TestSegmentsForCloudExadataInfrastructureId(t *testing.T) { + segments := CloudExadataInfrastructureId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CloudExadataInfrastructureId 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/oracledatabase/2024-06-01/cloudexadatainfrastructures/method_addstoragecapacity.go b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/method_addstoragecapacity.go new file mode 100644 index 00000000000..7b5bda2d476 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/method_addstoragecapacity.go @@ -0,0 +1,71 @@ +package cloudexadatainfrastructures + +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 AddStorageCapacityOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *CloudExadataInfrastructure +} + +// AddStorageCapacity ... +func (c CloudExadataInfrastructuresClient) AddStorageCapacity(ctx context.Context, id CloudExadataInfrastructureId) (result AddStorageCapacityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/addStorageCapacity", 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 +} + +// AddStorageCapacityThenPoll performs AddStorageCapacity then polls until it's completed +func (c CloudExadataInfrastructuresClient) AddStorageCapacityThenPoll(ctx context.Context, id CloudExadataInfrastructureId) error { + result, err := c.AddStorageCapacity(ctx, id) + if err != nil { + return fmt.Errorf("performing AddStorageCapacity: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after AddStorageCapacity: %+v", err) + } + + return nil +} diff --git a/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/method_createorupdate.go b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/method_createorupdate.go new file mode 100644 index 00000000000..75af32ddc64 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/method_createorupdate.go @@ -0,0 +1,75 @@ +package cloudexadatainfrastructures + +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 *CloudExadataInfrastructure +} + +// CreateOrUpdate ... +func (c CloudExadataInfrastructuresClient) CreateOrUpdate(ctx context.Context, id CloudExadataInfrastructureId, input CloudExadataInfrastructure) (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 CloudExadataInfrastructuresClient) CreateOrUpdateThenPoll(ctx context.Context, id CloudExadataInfrastructureId, input CloudExadataInfrastructure) 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/oracledatabase/2024-06-01/cloudexadatainfrastructures/method_delete.go b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/method_delete.go new file mode 100644 index 00000000000..f8032ba6b03 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/method_delete.go @@ -0,0 +1,70 @@ +package cloudexadatainfrastructures + +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 CloudExadataInfrastructuresClient) Delete(ctx context.Context, id CloudExadataInfrastructureId) (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 CloudExadataInfrastructuresClient) DeleteThenPoll(ctx context.Context, id CloudExadataInfrastructureId) 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/oracledatabase/2024-06-01/cloudexadatainfrastructures/method_get.go b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/method_get.go new file mode 100644 index 00000000000..f4c9c8b4e21 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/method_get.go @@ -0,0 +1,54 @@ +package cloudexadatainfrastructures + +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 *CloudExadataInfrastructure +} + +// Get ... +func (c CloudExadataInfrastructuresClient) Get(ctx context.Context, id CloudExadataInfrastructureId) (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 CloudExadataInfrastructure + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/method_listbyresourcegroup.go b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/method_listbyresourcegroup.go new file mode 100644 index 00000000000..2143b110959 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package cloudexadatainfrastructures + +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 *[]CloudExadataInfrastructure +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []CloudExadataInfrastructure +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c CloudExadataInfrastructuresClient) 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, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Oracle.Database/cloudExadataInfrastructures", 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 *[]CloudExadataInfrastructure `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 CloudExadataInfrastructuresClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, CloudExadataInfrastructureOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CloudExadataInfrastructuresClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate CloudExadataInfrastructureOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]CloudExadataInfrastructure, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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/oracledatabase/2024-06-01/cloudexadatainfrastructures/method_listbysubscription.go b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/method_listbysubscription.go new file mode 100644 index 00000000000..a6d4a182303 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/method_listbysubscription.go @@ -0,0 +1,106 @@ +package cloudexadatainfrastructures + +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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CloudExadataInfrastructure +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []CloudExadataInfrastructure +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c CloudExadataInfrastructuresClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Oracle.Database/cloudExadataInfrastructures", 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 *[]CloudExadataInfrastructure `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c CloudExadataInfrastructuresClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, CloudExadataInfrastructureOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CloudExadataInfrastructuresClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate CloudExadataInfrastructureOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]CloudExadataInfrastructure, 0) + + resp, err := c.ListBySubscription(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/method_update.go b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/method_update.go new file mode 100644 index 00000000000..54e2aa254c5 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/method_update.go @@ -0,0 +1,75 @@ +package cloudexadatainfrastructures + +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 *CloudExadataInfrastructure +} + +// Update ... +func (c CloudExadataInfrastructuresClient) Update(ctx context.Context, id CloudExadataInfrastructureId, input CloudExadataInfrastructureUpdate) (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 CloudExadataInfrastructuresClient) UpdateThenPoll(ctx context.Context, id CloudExadataInfrastructureId, input CloudExadataInfrastructureUpdate) 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/oracledatabase/2024-06-01/cloudexadatainfrastructures/model_cloudexadatainfrastructure.go b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/model_cloudexadatainfrastructure.go new file mode 100644 index 00000000000..93f4463e84f --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/model_cloudexadatainfrastructure.go @@ -0,0 +1,20 @@ +package cloudexadatainfrastructures + +import ( + "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 CloudExadataInfrastructure struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *CloudExadataInfrastructureProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones zones.Schema `json:"zones"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/model_cloudexadatainfrastructureproperties.go b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/model_cloudexadatainfrastructureproperties.go new file mode 100644 index 00000000000..e2cae85db86 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/model_cloudexadatainfrastructureproperties.go @@ -0,0 +1,38 @@ +package cloudexadatainfrastructures + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudExadataInfrastructureProperties struct { + ActivatedStorageCount *int64 `json:"activatedStorageCount,omitempty"` + AdditionalStorageCount *int64 `json:"additionalStorageCount,omitempty"` + AvailableStorageSizeInGbs *int64 `json:"availableStorageSizeInGbs,omitempty"` + ComputeCount *int64 `json:"computeCount,omitempty"` + CpuCount *int64 `json:"cpuCount,omitempty"` + CustomerContacts *[]CustomerContact `json:"customerContacts,omitempty"` + DataStorageSizeInTbs *float64 `json:"dataStorageSizeInTbs,omitempty"` + DbNodeStorageSizeInGbs *int64 `json:"dbNodeStorageSizeInGbs,omitempty"` + DbServerVersion *string `json:"dbServerVersion,omitempty"` + DisplayName string `json:"displayName"` + EstimatedPatchingTime *EstimatedPatchingTime `json:"estimatedPatchingTime,omitempty"` + LastMaintenanceRunId *string `json:"lastMaintenanceRunId,omitempty"` + LifecycleDetails *string `json:"lifecycleDetails,omitempty"` + LifecycleState *CloudExadataInfrastructureLifecycleState `json:"lifecycleState,omitempty"` + MaintenanceWindow *MaintenanceWindow `json:"maintenanceWindow,omitempty"` + MaxCPUCount *int64 `json:"maxCpuCount,omitempty"` + MaxDataStorageInTbs *float64 `json:"maxDataStorageInTbs,omitempty"` + MaxDbNodeStorageSizeInGbs *int64 `json:"maxDbNodeStorageSizeInGbs,omitempty"` + MaxMemoryInGbs *int64 `json:"maxMemoryInGbs,omitempty"` + MemorySizeInGbs *int64 `json:"memorySizeInGbs,omitempty"` + MonthlyDbServerVersion *string `json:"monthlyDbServerVersion,omitempty"` + MonthlyStorageServerVersion *string `json:"monthlyStorageServerVersion,omitempty"` + NextMaintenanceRunId *string `json:"nextMaintenanceRunId,omitempty"` + OciUrl *string `json:"ociUrl,omitempty"` + Ocid *string `json:"ocid,omitempty"` + ProvisioningState *AzureResourceProvisioningState `json:"provisioningState,omitempty"` + Shape string `json:"shape"` + StorageCount *int64 `json:"storageCount,omitempty"` + StorageServerVersion *string `json:"storageServerVersion,omitempty"` + TimeCreated *string `json:"timeCreated,omitempty"` + TotalStorageSizeInGbs *int64 `json:"totalStorageSizeInGbs,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/model_cloudexadatainfrastructureupdate.go b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/model_cloudexadatainfrastructureupdate.go new file mode 100644 index 00000000000..606eb24be43 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/model_cloudexadatainfrastructureupdate.go @@ -0,0 +1,14 @@ +package cloudexadatainfrastructures + +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 CloudExadataInfrastructureUpdate struct { + Properties *CloudExadataInfrastructureUpdateProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/model_cloudexadatainfrastructureupdateproperties.go b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/model_cloudexadatainfrastructureupdateproperties.go new file mode 100644 index 00000000000..d18c7da0d01 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/model_cloudexadatainfrastructureupdateproperties.go @@ -0,0 +1,12 @@ +package cloudexadatainfrastructures + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudExadataInfrastructureUpdateProperties struct { + ComputeCount *int64 `json:"computeCount,omitempty"` + CustomerContacts *[]CustomerContact `json:"customerContacts,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + MaintenanceWindow *MaintenanceWindow `json:"maintenanceWindow,omitempty"` + StorageCount *int64 `json:"storageCount,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/model_customercontact.go b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/model_customercontact.go new file mode 100644 index 00000000000..ab32a4c955d --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/model_customercontact.go @@ -0,0 +1,8 @@ +package cloudexadatainfrastructures + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomerContact struct { + Email string `json:"email"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/model_dayofweek.go b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/model_dayofweek.go new file mode 100644 index 00000000000..0df53b97a8f --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/model_dayofweek.go @@ -0,0 +1,8 @@ +package cloudexadatainfrastructures + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DayOfWeek struct { + Name DayOfWeekName `json:"name"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/model_estimatedpatchingtime.go b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/model_estimatedpatchingtime.go new file mode 100644 index 00000000000..52cd0d6fa9e --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/model_estimatedpatchingtime.go @@ -0,0 +1,11 @@ +package cloudexadatainfrastructures + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EstimatedPatchingTime struct { + EstimatedDbServerPatchingTime *int64 `json:"estimatedDbServerPatchingTime,omitempty"` + EstimatedNetworkSwitchesPatchingTime *int64 `json:"estimatedNetworkSwitchesPatchingTime,omitempty"` + EstimatedStorageServerPatchingTime *int64 `json:"estimatedStorageServerPatchingTime,omitempty"` + TotalEstimatedPatchingTime *int64 `json:"totalEstimatedPatchingTime,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/model_maintenancewindow.go b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/model_maintenancewindow.go new file mode 100644 index 00000000000..b9d485dcf62 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/model_maintenancewindow.go @@ -0,0 +1,17 @@ +package cloudexadatainfrastructures + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MaintenanceWindow struct { + CustomActionTimeoutInMins *int64 `json:"customActionTimeoutInMins,omitempty"` + DaysOfWeek *[]DayOfWeek `json:"daysOfWeek,omitempty"` + HoursOfDay *[]int64 `json:"hoursOfDay,omitempty"` + IsCustomActionTimeoutEnabled *bool `json:"isCustomActionTimeoutEnabled,omitempty"` + IsMonthlyPatchingEnabled *bool `json:"isMonthlyPatchingEnabled,omitempty"` + LeadTimeInWeeks *int64 `json:"leadTimeInWeeks,omitempty"` + Months *[]Month `json:"months,omitempty"` + PatchingMode *PatchingMode `json:"patchingMode,omitempty"` + Preference *Preference `json:"preference,omitempty"` + WeeksOfMonth *[]int64 `json:"weeksOfMonth,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/model_month.go b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/model_month.go new file mode 100644 index 00000000000..9c0b630b8af --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/model_month.go @@ -0,0 +1,8 @@ +package cloudexadatainfrastructures + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Month struct { + Name MonthName `json:"name"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/predicates.go b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/predicates.go new file mode 100644 index 00000000000..f34f9935407 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/predicates.go @@ -0,0 +1,32 @@ +package cloudexadatainfrastructures + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudExadataInfrastructureOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p CloudExadataInfrastructureOperationPredicate) Matches(input CloudExadataInfrastructure) 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/oracledatabase/2024-06-01/cloudexadatainfrastructures/version.go b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/version.go new file mode 100644 index 00000000000..5296ca89a86 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudexadatainfrastructures/version.go @@ -0,0 +1,12 @@ +package cloudexadatainfrastructures + +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-06-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/cloudexadatainfrastructures/%s", defaultApiVersion) +} diff --git a/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/README.md b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/README.md new file mode 100644 index 00000000000..408b369e0f2 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/README.md @@ -0,0 +1,172 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/cloudvmclusters` Documentation + +The `cloudvmclusters` SDK allows for interaction with the Azure Resource Manager Service `oracledatabase` (API Version `2024-06-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/oracledatabase/2024-06-01/cloudvmclusters" +``` + + +### Client Initialization + +```go +client := cloudvmclusters.NewCloudVMClustersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CloudVMClustersClient.AddVMs` + +```go +ctx := context.TODO() +id := cloudvmclusters.NewCloudVMClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudVmClusterValue") + +payload := cloudvmclusters.AddRemoveDbNode{ + // ... +} + + +if err := client.AddVMsThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CloudVMClustersClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := cloudvmclusters.NewCloudVMClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudVmClusterValue") + +payload := cloudvmclusters.CloudVMCluster{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CloudVMClustersClient.Delete` + +```go +ctx := context.TODO() +id := cloudvmclusters.NewCloudVMClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudVmClusterValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CloudVMClustersClient.Get` + +```go +ctx := context.TODO() +id := cloudvmclusters.NewCloudVMClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudVmClusterValue") + +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: `CloudVMClustersClient.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: `CloudVMClustersClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `CloudVMClustersClient.ListPrivateIPAddresses` + +```go +ctx := context.TODO() +id := cloudvmclusters.NewCloudVMClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudVmClusterValue") + +payload := cloudvmclusters.PrivateIPAddressesFilter{ + // ... +} + + +read, err := client.ListPrivateIPAddresses(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CloudVMClustersClient.RemoveVMs` + +```go +ctx := context.TODO() +id := cloudvmclusters.NewCloudVMClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudVmClusterValue") + +payload := cloudvmclusters.AddRemoveDbNode{ + // ... +} + + +if err := client.RemoveVMsThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CloudVMClustersClient.Update` + +```go +ctx := context.TODO() +id := cloudvmclusters.NewCloudVMClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudVmClusterValue") + +payload := cloudvmclusters.CloudVMClusterUpdate{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/client.go b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/client.go new file mode 100644 index 00000000000..7bc1de89393 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/client.go @@ -0,0 +1,26 @@ +package cloudvmclusters + +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 CloudVMClustersClient struct { + Client *resourcemanager.Client +} + +func NewCloudVMClustersClientWithBaseURI(sdkApi sdkEnv.Api) (*CloudVMClustersClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "cloudvmclusters", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CloudVMClustersClient: %+v", err) + } + + return &CloudVMClustersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/constants.go b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/constants.go new file mode 100644 index 00000000000..5315231510d --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/constants.go @@ -0,0 +1,295 @@ +package cloudvmclusters + +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 AzureResourceProvisioningState string + +const ( + AzureResourceProvisioningStateCanceled AzureResourceProvisioningState = "Canceled" + AzureResourceProvisioningStateFailed AzureResourceProvisioningState = "Failed" + AzureResourceProvisioningStateProvisioning AzureResourceProvisioningState = "Provisioning" + AzureResourceProvisioningStateSucceeded AzureResourceProvisioningState = "Succeeded" +) + +func PossibleValuesForAzureResourceProvisioningState() []string { + return []string{ + string(AzureResourceProvisioningStateCanceled), + string(AzureResourceProvisioningStateFailed), + string(AzureResourceProvisioningStateProvisioning), + string(AzureResourceProvisioningStateSucceeded), + } +} + +func (s *AzureResourceProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureResourceProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureResourceProvisioningState(input string) (*AzureResourceProvisioningState, error) { + vals := map[string]AzureResourceProvisioningState{ + "canceled": AzureResourceProvisioningStateCanceled, + "failed": AzureResourceProvisioningStateFailed, + "provisioning": AzureResourceProvisioningStateProvisioning, + "succeeded": AzureResourceProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureResourceProvisioningState(input) + return &out, nil +} + +type CloudVMClusterLifecycleState string + +const ( + CloudVMClusterLifecycleStateAvailable CloudVMClusterLifecycleState = "Available" + CloudVMClusterLifecycleStateFailed CloudVMClusterLifecycleState = "Failed" + CloudVMClusterLifecycleStateMaintenanceInProgress CloudVMClusterLifecycleState = "MaintenanceInProgress" + CloudVMClusterLifecycleStateProvisioning CloudVMClusterLifecycleState = "Provisioning" + CloudVMClusterLifecycleStateTerminated CloudVMClusterLifecycleState = "Terminated" + CloudVMClusterLifecycleStateTerminating CloudVMClusterLifecycleState = "Terminating" + CloudVMClusterLifecycleStateUpdating CloudVMClusterLifecycleState = "Updating" +) + +func PossibleValuesForCloudVMClusterLifecycleState() []string { + return []string{ + string(CloudVMClusterLifecycleStateAvailable), + string(CloudVMClusterLifecycleStateFailed), + string(CloudVMClusterLifecycleStateMaintenanceInProgress), + string(CloudVMClusterLifecycleStateProvisioning), + string(CloudVMClusterLifecycleStateTerminated), + string(CloudVMClusterLifecycleStateTerminating), + string(CloudVMClusterLifecycleStateUpdating), + } +} + +func (s *CloudVMClusterLifecycleState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCloudVMClusterLifecycleState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCloudVMClusterLifecycleState(input string) (*CloudVMClusterLifecycleState, error) { + vals := map[string]CloudVMClusterLifecycleState{ + "available": CloudVMClusterLifecycleStateAvailable, + "failed": CloudVMClusterLifecycleStateFailed, + "maintenanceinprogress": CloudVMClusterLifecycleStateMaintenanceInProgress, + "provisioning": CloudVMClusterLifecycleStateProvisioning, + "terminated": CloudVMClusterLifecycleStateTerminated, + "terminating": CloudVMClusterLifecycleStateTerminating, + "updating": CloudVMClusterLifecycleStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CloudVMClusterLifecycleState(input) + return &out, nil +} + +type DiskRedundancy string + +const ( + DiskRedundancyHigh DiskRedundancy = "High" + DiskRedundancyNormal DiskRedundancy = "Normal" +) + +func PossibleValuesForDiskRedundancy() []string { + return []string{ + string(DiskRedundancyHigh), + string(DiskRedundancyNormal), + } +} + +func (s *DiskRedundancy) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDiskRedundancy(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDiskRedundancy(input string) (*DiskRedundancy, error) { + vals := map[string]DiskRedundancy{ + "high": DiskRedundancyHigh, + "normal": DiskRedundancyNormal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DiskRedundancy(input) + return &out, nil +} + +type IormLifecycleState string + +const ( + IormLifecycleStateBootStrapping IormLifecycleState = "BootStrapping" + IormLifecycleStateDisabled IormLifecycleState = "Disabled" + IormLifecycleStateEnabled IormLifecycleState = "Enabled" + IormLifecycleStateFailed IormLifecycleState = "Failed" + IormLifecycleStateUpdating IormLifecycleState = "Updating" +) + +func PossibleValuesForIormLifecycleState() []string { + return []string{ + string(IormLifecycleStateBootStrapping), + string(IormLifecycleStateDisabled), + string(IormLifecycleStateEnabled), + string(IormLifecycleStateFailed), + string(IormLifecycleStateUpdating), + } +} + +func (s *IormLifecycleState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIormLifecycleState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIormLifecycleState(input string) (*IormLifecycleState, error) { + vals := map[string]IormLifecycleState{ + "bootstrapping": IormLifecycleStateBootStrapping, + "disabled": IormLifecycleStateDisabled, + "enabled": IormLifecycleStateEnabled, + "failed": IormLifecycleStateFailed, + "updating": IormLifecycleStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IormLifecycleState(input) + return &out, nil +} + +type LicenseModel string + +const ( + LicenseModelBringYourOwnLicense LicenseModel = "BringYourOwnLicense" + LicenseModelLicenseIncluded LicenseModel = "LicenseIncluded" +) + +func PossibleValuesForLicenseModel() []string { + return []string{ + string(LicenseModelBringYourOwnLicense), + string(LicenseModelLicenseIncluded), + } +} + +func (s *LicenseModel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLicenseModel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLicenseModel(input string) (*LicenseModel, error) { + vals := map[string]LicenseModel{ + "bringyourownlicense": LicenseModelBringYourOwnLicense, + "licenseincluded": LicenseModelLicenseIncluded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LicenseModel(input) + return &out, nil +} + +type Objective string + +const ( + ObjectiveAuto Objective = "Auto" + ObjectiveBalanced Objective = "Balanced" + ObjectiveBasic Objective = "Basic" + ObjectiveHighThroughput Objective = "HighThroughput" + ObjectiveLowLatency Objective = "LowLatency" +) + +func PossibleValuesForObjective() []string { + return []string{ + string(ObjectiveAuto), + string(ObjectiveBalanced), + string(ObjectiveBasic), + string(ObjectiveHighThroughput), + string(ObjectiveLowLatency), + } +} + +func (s *Objective) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseObjective(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseObjective(input string) (*Objective, error) { + vals := map[string]Objective{ + "auto": ObjectiveAuto, + "balanced": ObjectiveBalanced, + "basic": ObjectiveBasic, + "highthroughput": ObjectiveHighThroughput, + "lowlatency": ObjectiveLowLatency, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Objective(input) + return &out, nil +} diff --git a/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/id_cloudvmcluster.go b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/id_cloudvmcluster.go new file mode 100644 index 00000000000..1398a3825d3 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/id_cloudvmcluster.go @@ -0,0 +1,130 @@ +package cloudvmclusters + +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(&CloudVMClusterId{}) +} + +var _ resourceids.ResourceId = &CloudVMClusterId{} + +// CloudVMClusterId is a struct representing the Resource ID for a Cloud V M Cluster +type CloudVMClusterId struct { + SubscriptionId string + ResourceGroupName string + CloudVmClusterName string +} + +// NewCloudVMClusterID returns a new CloudVMClusterId struct +func NewCloudVMClusterID(subscriptionId string, resourceGroupName string, cloudVmClusterName string) CloudVMClusterId { + return CloudVMClusterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CloudVmClusterName: cloudVmClusterName, + } +} + +// ParseCloudVMClusterID parses 'input' into a CloudVMClusterId +func ParseCloudVMClusterID(input string) (*CloudVMClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&CloudVMClusterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CloudVMClusterId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCloudVMClusterIDInsensitively parses 'input' case-insensitively into a CloudVMClusterId +// note: this method should only be used for API response data and not user input +func ParseCloudVMClusterIDInsensitively(input string) (*CloudVMClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&CloudVMClusterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CloudVMClusterId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CloudVMClusterId) 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.CloudVmClusterName, ok = input.Parsed["cloudVmClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "cloudVmClusterName", input) + } + + return nil +} + +// ValidateCloudVMClusterID checks that 'input' can be parsed as a Cloud V M Cluster ID +func ValidateCloudVMClusterID(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 := ParseCloudVMClusterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Cloud V M Cluster ID +func (id CloudVMClusterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Oracle.Database/cloudVmClusters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CloudVmClusterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Cloud V M Cluster ID +func (id CloudVMClusterId) 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("staticOracleDatabase", "Oracle.Database", "Oracle.Database"), + resourceids.StaticSegment("staticCloudVmClusters", "cloudVmClusters", "cloudVmClusters"), + resourceids.UserSpecifiedSegment("cloudVmClusterName", "cloudVmClusterValue"), + } +} + +// String returns a human-readable description of this Cloud V M Cluster ID +func (id CloudVMClusterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cloud Vm Cluster Name: %q", id.CloudVmClusterName), + } + return fmt.Sprintf("Cloud V M Cluster (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/id_cloudvmcluster_test.go b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/id_cloudvmcluster_test.go new file mode 100644 index 00000000000..a76dd99b971 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/id_cloudvmcluster_test.go @@ -0,0 +1,282 @@ +package cloudvmclusters + +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 = &CloudVMClusterId{} + +func TestNewCloudVMClusterID(t *testing.T) { + id := NewCloudVMClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudVmClusterValue") + + 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.CloudVmClusterName != "cloudVmClusterValue" { + t.Fatalf("Expected %q but got %q for Segment 'CloudVmClusterName'", id.CloudVmClusterName, "cloudVmClusterValue") + } +} + +func TestFormatCloudVMClusterID(t *testing.T) { + actual := NewCloudVMClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudVmClusterValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudVmClusters/cloudVmClusterValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCloudVMClusterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CloudVMClusterId + }{ + { + // 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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudVmClusters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudVmClusters/cloudVmClusterValue", + Expected: &CloudVMClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudVmClusterName: "cloudVmClusterValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudVmClusters/cloudVmClusterValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCloudVMClusterID(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.CloudVmClusterName != v.Expected.CloudVmClusterName { + t.Fatalf("Expected %q but got %q for CloudVmClusterName", v.Expected.CloudVmClusterName, actual.CloudVmClusterName) + } + + } +} + +func TestParseCloudVMClusterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CloudVMClusterId + }{ + { + // 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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudVmClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe/cLoUdVmClUsTeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudVmClusters/cloudVmClusterValue", + Expected: &CloudVMClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudVmClusterName: "cloudVmClusterValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudVmClusters/cloudVmClusterValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe/cLoUdVmClUsTeRs/cLoUdVmClUsTeRvAlUe", + Expected: &CloudVMClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CloudVmClusterName: "cLoUdVmClUsTeRvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe/cLoUdVmClUsTeRs/cLoUdVmClUsTeRvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCloudVMClusterIDInsensitively(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.CloudVmClusterName != v.Expected.CloudVmClusterName { + t.Fatalf("Expected %q but got %q for CloudVmClusterName", v.Expected.CloudVmClusterName, actual.CloudVmClusterName) + } + + } +} + +func TestSegmentsForCloudVMClusterId(t *testing.T) { + segments := CloudVMClusterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CloudVMClusterId 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/oracledatabase/2024-06-01/cloudvmclusters/method_addvms.go b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/method_addvms.go new file mode 100644 index 00000000000..f83b1419e29 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/method_addvms.go @@ -0,0 +1,75 @@ +package cloudvmclusters + +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 AddVMsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *CloudVMCluster +} + +// AddVMs ... +func (c CloudVMClustersClient) AddVMs(ctx context.Context, id CloudVMClusterId, input AddRemoveDbNode) (result AddVMsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/addVms", 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 +} + +// AddVMsThenPoll performs AddVMs then polls until it's completed +func (c CloudVMClustersClient) AddVMsThenPoll(ctx context.Context, id CloudVMClusterId, input AddRemoveDbNode) error { + result, err := c.AddVMs(ctx, id, input) + if err != nil { + return fmt.Errorf("performing AddVMs: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after AddVMs: %+v", err) + } + + return nil +} diff --git a/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/method_createorupdate.go b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/method_createorupdate.go new file mode 100644 index 00000000000..d4006bf71a3 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/method_createorupdate.go @@ -0,0 +1,75 @@ +package cloudvmclusters + +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 *CloudVMCluster +} + +// CreateOrUpdate ... +func (c CloudVMClustersClient) CreateOrUpdate(ctx context.Context, id CloudVMClusterId, input CloudVMCluster) (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 CloudVMClustersClient) CreateOrUpdateThenPoll(ctx context.Context, id CloudVMClusterId, input CloudVMCluster) 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/oracledatabase/2024-06-01/cloudvmclusters/method_delete.go b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/method_delete.go new file mode 100644 index 00000000000..d8297753935 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/method_delete.go @@ -0,0 +1,70 @@ +package cloudvmclusters + +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 CloudVMClustersClient) Delete(ctx context.Context, id CloudVMClusterId) (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 CloudVMClustersClient) DeleteThenPoll(ctx context.Context, id CloudVMClusterId) 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/oracledatabase/2024-06-01/cloudvmclusters/method_get.go b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/method_get.go new file mode 100644 index 00000000000..3b1646ab44c --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/method_get.go @@ -0,0 +1,54 @@ +package cloudvmclusters + +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 *CloudVMCluster +} + +// Get ... +func (c CloudVMClustersClient) Get(ctx context.Context, id CloudVMClusterId) (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 CloudVMCluster + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/method_listbyresourcegroup.go b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/method_listbyresourcegroup.go new file mode 100644 index 00000000000..c6f023cd917 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package cloudvmclusters + +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 *[]CloudVMCluster +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []CloudVMCluster +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c CloudVMClustersClient) 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, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Oracle.Database/cloudVmClusters", 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 *[]CloudVMCluster `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 CloudVMClustersClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, CloudVMClusterOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CloudVMClustersClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate CloudVMClusterOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]CloudVMCluster, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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/oracledatabase/2024-06-01/cloudvmclusters/method_listbysubscription.go b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/method_listbysubscription.go new file mode 100644 index 00000000000..dfd4dafe734 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/method_listbysubscription.go @@ -0,0 +1,106 @@ +package cloudvmclusters + +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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CloudVMCluster +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []CloudVMCluster +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c CloudVMClustersClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Oracle.Database/cloudVmClusters", 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 *[]CloudVMCluster `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c CloudVMClustersClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, CloudVMClusterOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CloudVMClustersClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate CloudVMClusterOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]CloudVMCluster, 0) + + resp, err := c.ListBySubscription(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/method_listprivateipaddresses.go b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/method_listprivateipaddresses.go new file mode 100644 index 00000000000..d0a7fbe2ebb --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/method_listprivateipaddresses.go @@ -0,0 +1,59 @@ +package cloudvmclusters + +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 ListPrivateIPAddressesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PrivateIPAddressProperties +} + +// ListPrivateIPAddresses ... +func (c CloudVMClustersClient) ListPrivateIPAddresses(ctx context.Context, id CloudVMClusterId, input PrivateIPAddressesFilter) (result ListPrivateIPAddressesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listPrivateIpAddresses", 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 []PrivateIPAddressProperties + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/method_removevms.go b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/method_removevms.go new file mode 100644 index 00000000000..6b285c4817a --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/method_removevms.go @@ -0,0 +1,75 @@ +package cloudvmclusters + +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 RemoveVMsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *CloudVMCluster +} + +// RemoveVMs ... +func (c CloudVMClustersClient) RemoveVMs(ctx context.Context, id CloudVMClusterId, input AddRemoveDbNode) (result RemoveVMsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/removeVms", 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 +} + +// RemoveVMsThenPoll performs RemoveVMs then polls until it's completed +func (c CloudVMClustersClient) RemoveVMsThenPoll(ctx context.Context, id CloudVMClusterId, input AddRemoveDbNode) error { + result, err := c.RemoveVMs(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RemoveVMs: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RemoveVMs: %+v", err) + } + + return nil +} diff --git a/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/method_update.go b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/method_update.go new file mode 100644 index 00000000000..b629960e83d --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/method_update.go @@ -0,0 +1,75 @@ +package cloudvmclusters + +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 *CloudVMCluster +} + +// Update ... +func (c CloudVMClustersClient) Update(ctx context.Context, id CloudVMClusterId, input CloudVMClusterUpdate) (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 CloudVMClustersClient) UpdateThenPoll(ctx context.Context, id CloudVMClusterId, input CloudVMClusterUpdate) 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/oracledatabase/2024-06-01/cloudvmclusters/model_addremovedbnode.go b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/model_addremovedbnode.go new file mode 100644 index 00000000000..4339e88ab71 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/model_addremovedbnode.go @@ -0,0 +1,8 @@ +package cloudvmclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddRemoveDbNode struct { + DbServers []string `json:"dbServers"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/model_cloudvmcluster.go b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/model_cloudvmcluster.go new file mode 100644 index 00000000000..794313d5e11 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/model_cloudvmcluster.go @@ -0,0 +1,18 @@ +package cloudvmclusters + +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 CloudVMCluster struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *CloudVMClusterProperties `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/oracledatabase/2024-06-01/cloudvmclusters/model_cloudvmclusterproperties.go b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/model_cloudvmclusterproperties.go new file mode 100644 index 00000000000..73a09d1f15d --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/model_cloudvmclusterproperties.go @@ -0,0 +1,73 @@ +package cloudvmclusters + +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 CloudVMClusterProperties struct { + BackupSubnetCidr *string `json:"backupSubnetCidr,omitempty"` + CloudExadataInfrastructureId string `json:"cloudExadataInfrastructureId"` + ClusterName *string `json:"clusterName,omitempty"` + CompartmentId *string `json:"compartmentId,omitempty"` + ComputeNodes *[]string `json:"computeNodes,omitempty"` + CpuCoreCount int64 `json:"cpuCoreCount"` + DataCollectionOptions *DataCollectionOptions `json:"dataCollectionOptions,omitempty"` + DataStoragePercentage *int64 `json:"dataStoragePercentage,omitempty"` + DataStorageSizeInTbs *float64 `json:"dataStorageSizeInTbs,omitempty"` + DbNodeStorageSizeInGbs *int64 `json:"dbNodeStorageSizeInGbs,omitempty"` + DbServers *[]string `json:"dbServers,omitempty"` + DiskRedundancy *DiskRedundancy `json:"diskRedundancy,omitempty"` + DisplayName string `json:"displayName"` + Domain *string `json:"domain,omitempty"` + GiVersion string `json:"giVersion"` + Hostname string `json:"hostname"` + IormConfigCache *ExadataIormConfig `json:"iormConfigCache,omitempty"` + IsLocalBackupEnabled *bool `json:"isLocalBackupEnabled,omitempty"` + IsSparseDiskgroupEnabled *bool `json:"isSparseDiskgroupEnabled,omitempty"` + LastUpdateHistoryEntryId *string `json:"lastUpdateHistoryEntryId,omitempty"` + LicenseModel *LicenseModel `json:"licenseModel,omitempty"` + LifecycleDetails *string `json:"lifecycleDetails,omitempty"` + LifecycleState *CloudVMClusterLifecycleState `json:"lifecycleState,omitempty"` + ListenerPort *int64 `json:"listenerPort,omitempty"` + MemorySizeInGbs *int64 `json:"memorySizeInGbs,omitempty"` + NodeCount *int64 `json:"nodeCount,omitempty"` + NsgCidrs *[]NsgCidr `json:"nsgCidrs,omitempty"` + NsgUrl *string `json:"nsgUrl,omitempty"` + OciUrl *string `json:"ociUrl,omitempty"` + Ocid *string `json:"ocid,omitempty"` + OcpuCount *float64 `json:"ocpuCount,omitempty"` + ProvisioningState *AzureResourceProvisioningState `json:"provisioningState,omitempty"` + ScanDnsName *string `json:"scanDnsName,omitempty"` + ScanDnsRecordId *string `json:"scanDnsRecordId,omitempty"` + ScanIPIds *[]string `json:"scanIpIds,omitempty"` + ScanListenerPortTcp *int64 `json:"scanListenerPortTcp,omitempty"` + ScanListenerPortTcpSsl *int64 `json:"scanListenerPortTcpSsl,omitempty"` + Shape *string `json:"shape,omitempty"` + SshPublicKeys []string `json:"sshPublicKeys"` + StorageSizeInGbs *int64 `json:"storageSizeInGbs,omitempty"` + SubnetId string `json:"subnetId"` + SubnetOcid *string `json:"subnetOcid,omitempty"` + SystemVersion *string `json:"systemVersion,omitempty"` + TimeCreated *string `json:"timeCreated,omitempty"` + TimeZone *string `json:"timeZone,omitempty"` + VipIds *[]string `json:"vipIds,omitempty"` + VnetId string `json:"vnetId"` + ZoneId *string `json:"zoneId,omitempty"` +} + +func (o *CloudVMClusterProperties) GetTimeCreatedAsTime() (*time.Time, error) { + if o.TimeCreated == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeCreated, "2006-01-02T15:04:05Z07:00") +} + +func (o *CloudVMClusterProperties) SetTimeCreatedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeCreated = &formatted +} diff --git a/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/model_cloudvmclusterupdate.go b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/model_cloudvmclusterupdate.go new file mode 100644 index 00000000000..9c45a82caab --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/model_cloudvmclusterupdate.go @@ -0,0 +1,9 @@ +package cloudvmclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudVMClusterUpdate struct { + Properties *CloudVMClusterUpdateProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/model_cloudvmclusterupdateproperties.go b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/model_cloudvmclusterupdateproperties.go new file mode 100644 index 00000000000..b6499789da8 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/model_cloudvmclusterupdateproperties.go @@ -0,0 +1,18 @@ +package cloudvmclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudVMClusterUpdateProperties struct { + ComputeNodes *[]string `json:"computeNodes,omitempty"` + CpuCoreCount *int64 `json:"cpuCoreCount,omitempty"` + DataCollectionOptions *DataCollectionOptions `json:"dataCollectionOptions,omitempty"` + DataStorageSizeInTbs *float64 `json:"dataStorageSizeInTbs,omitempty"` + DbNodeStorageSizeInGbs *int64 `json:"dbNodeStorageSizeInGbs,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + LicenseModel *LicenseModel `json:"licenseModel,omitempty"` + MemorySizeInGbs *int64 `json:"memorySizeInGbs,omitempty"` + OcpuCount *float64 `json:"ocpuCount,omitempty"` + SshPublicKeys *[]string `json:"sshPublicKeys,omitempty"` + StorageSizeInGbs *int64 `json:"storageSizeInGbs,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/model_datacollectionoptions.go b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/model_datacollectionoptions.go new file mode 100644 index 00000000000..df3ddfd596d --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/model_datacollectionoptions.go @@ -0,0 +1,10 @@ +package cloudvmclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataCollectionOptions struct { + IsDiagnosticsEventsEnabled *bool `json:"isDiagnosticsEventsEnabled,omitempty"` + IsHealthMonitoringEnabled *bool `json:"isHealthMonitoringEnabled,omitempty"` + IsIncidentLogsEnabled *bool `json:"isIncidentLogsEnabled,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/model_dbiormconfig.go b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/model_dbiormconfig.go new file mode 100644 index 00000000000..3ec47756c25 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/model_dbiormconfig.go @@ -0,0 +1,10 @@ +package cloudvmclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DbIormConfig struct { + DbName *string `json:"dbName,omitempty"` + FlashCacheLimit *string `json:"flashCacheLimit,omitempty"` + Share *int64 `json:"share,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/model_exadataiormconfig.go b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/model_exadataiormconfig.go new file mode 100644 index 00000000000..07899f1e94d --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/model_exadataiormconfig.go @@ -0,0 +1,11 @@ +package cloudvmclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExadataIormConfig struct { + DbPlans *[]DbIormConfig `json:"dbPlans,omitempty"` + LifecycleDetails *string `json:"lifecycleDetails,omitempty"` + LifecycleState *IormLifecycleState `json:"lifecycleState,omitempty"` + Objective *Objective `json:"objective,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/model_nsgcidr.go b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/model_nsgcidr.go new file mode 100644 index 00000000000..7123fc5a165 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/model_nsgcidr.go @@ -0,0 +1,9 @@ +package cloudvmclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NsgCidr struct { + DestinationPortRange *PortRange `json:"destinationPortRange,omitempty"` + Source string `json:"source"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/model_portrange.go b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/model_portrange.go new file mode 100644 index 00000000000..a3906443e6a --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/model_portrange.go @@ -0,0 +1,9 @@ +package cloudvmclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PortRange struct { + Max int64 `json:"max"` + Min int64 `json:"min"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/model_privateipaddressesfilter.go b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/model_privateipaddressesfilter.go new file mode 100644 index 00000000000..4986845bb03 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/model_privateipaddressesfilter.go @@ -0,0 +1,9 @@ +package cloudvmclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateIPAddressesFilter struct { + SubnetId string `json:"subnetId"` + VnicId string `json:"vnicId"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/model_privateipaddressproperties.go b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/model_privateipaddressproperties.go new file mode 100644 index 00000000000..35ac2a7af42 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/model_privateipaddressproperties.go @@ -0,0 +1,12 @@ +package cloudvmclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateIPAddressProperties struct { + DisplayName string `json:"displayName"` + HostnameLabel string `json:"hostnameLabel"` + IPAddress string `json:"ipAddress"` + Ocid string `json:"ocid"` + SubnetId string `json:"subnetId"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/predicates.go b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/predicates.go new file mode 100644 index 00000000000..174e49c11ca --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/predicates.go @@ -0,0 +1,32 @@ +package cloudvmclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudVMClusterOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p CloudVMClusterOperationPredicate) Matches(input CloudVMCluster) 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/oracledatabase/2024-06-01/cloudvmclusters/version.go b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/version.go new file mode 100644 index 00000000000..75e614772c8 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/cloudvmclusters/version.go @@ -0,0 +1,12 @@ +package cloudvmclusters + +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-06-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/cloudvmclusters/%s", defaultApiVersion) +} diff --git a/resource-manager/oracledatabase/2024-06-01/dbnodes/README.md b/resource-manager/oracledatabase/2024-06-01/dbnodes/README.md new file mode 100644 index 00000000000..8969a93de41 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dbnodes/README.md @@ -0,0 +1,70 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/dbnodes` Documentation + +The `dbnodes` SDK allows for interaction with the Azure Resource Manager Service `oracledatabase` (API Version `2024-06-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/oracledatabase/2024-06-01/dbnodes" +``` + + +### Client Initialization + +```go +client := dbnodes.NewDbNodesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DbNodesClient.Action` + +```go +ctx := context.TODO() +id := dbnodes.NewDbNodeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudVmClusterValue", "dbNodeValue") + +payload := dbnodes.DbNodeAction{ + // ... +} + + +if err := client.ActionThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `DbNodesClient.Get` + +```go +ctx := context.TODO() +id := dbnodes.NewDbNodeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudVmClusterValue", "dbNodeValue") + +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: `DbNodesClient.ListByCloudVMCluster` + +```go +ctx := context.TODO() +id := dbnodes.NewCloudVMClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudVmClusterValue") + +// alternatively `client.ListByCloudVMCluster(ctx, id)` can be used to do batched pagination +items, err := client.ListByCloudVMClusterComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/oracledatabase/2024-06-01/dbnodes/client.go b/resource-manager/oracledatabase/2024-06-01/dbnodes/client.go new file mode 100644 index 00000000000..ad2d02fbb1f --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dbnodes/client.go @@ -0,0 +1,26 @@ +package dbnodes + +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 DbNodesClient struct { + Client *resourcemanager.Client +} + +func NewDbNodesClientWithBaseURI(sdkApi sdkEnv.Api) (*DbNodesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "dbnodes", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DbNodesClient: %+v", err) + } + + return &DbNodesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/oracledatabase/2024-06-01/dbnodes/constants.go b/resource-manager/oracledatabase/2024-06-01/dbnodes/constants.go new file mode 100644 index 00000000000..f0304b7d961 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dbnodes/constants.go @@ -0,0 +1,201 @@ +package dbnodes + +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 DbNodeActionEnum string + +const ( + DbNodeActionEnumReset DbNodeActionEnum = "Reset" + DbNodeActionEnumSoftReset DbNodeActionEnum = "SoftReset" + DbNodeActionEnumStart DbNodeActionEnum = "Start" + DbNodeActionEnumStop DbNodeActionEnum = "Stop" +) + +func PossibleValuesForDbNodeActionEnum() []string { + return []string{ + string(DbNodeActionEnumReset), + string(DbNodeActionEnumSoftReset), + string(DbNodeActionEnumStart), + string(DbNodeActionEnumStop), + } +} + +func (s *DbNodeActionEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDbNodeActionEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDbNodeActionEnum(input string) (*DbNodeActionEnum, error) { + vals := map[string]DbNodeActionEnum{ + "reset": DbNodeActionEnumReset, + "softreset": DbNodeActionEnumSoftReset, + "start": DbNodeActionEnumStart, + "stop": DbNodeActionEnumStop, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DbNodeActionEnum(input) + return &out, nil +} + +type DbNodeMaintenanceType string + +const ( + DbNodeMaintenanceTypeVMdbRebootMigration DbNodeMaintenanceType = "VmdbRebootMigration" +) + +func PossibleValuesForDbNodeMaintenanceType() []string { + return []string{ + string(DbNodeMaintenanceTypeVMdbRebootMigration), + } +} + +func (s *DbNodeMaintenanceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDbNodeMaintenanceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDbNodeMaintenanceType(input string) (*DbNodeMaintenanceType, error) { + vals := map[string]DbNodeMaintenanceType{ + "vmdbrebootmigration": DbNodeMaintenanceTypeVMdbRebootMigration, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DbNodeMaintenanceType(input) + return &out, nil +} + +type DbNodeProvisioningState string + +const ( + DbNodeProvisioningStateAvailable DbNodeProvisioningState = "Available" + DbNodeProvisioningStateFailed DbNodeProvisioningState = "Failed" + DbNodeProvisioningStateProvisioning DbNodeProvisioningState = "Provisioning" + DbNodeProvisioningStateStarting DbNodeProvisioningState = "Starting" + DbNodeProvisioningStateStopped DbNodeProvisioningState = "Stopped" + DbNodeProvisioningStateStopping DbNodeProvisioningState = "Stopping" + DbNodeProvisioningStateTerminated DbNodeProvisioningState = "Terminated" + DbNodeProvisioningStateTerminating DbNodeProvisioningState = "Terminating" + DbNodeProvisioningStateUpdating DbNodeProvisioningState = "Updating" +) + +func PossibleValuesForDbNodeProvisioningState() []string { + return []string{ + string(DbNodeProvisioningStateAvailable), + string(DbNodeProvisioningStateFailed), + string(DbNodeProvisioningStateProvisioning), + string(DbNodeProvisioningStateStarting), + string(DbNodeProvisioningStateStopped), + string(DbNodeProvisioningStateStopping), + string(DbNodeProvisioningStateTerminated), + string(DbNodeProvisioningStateTerminating), + string(DbNodeProvisioningStateUpdating), + } +} + +func (s *DbNodeProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDbNodeProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDbNodeProvisioningState(input string) (*DbNodeProvisioningState, error) { + vals := map[string]DbNodeProvisioningState{ + "available": DbNodeProvisioningStateAvailable, + "failed": DbNodeProvisioningStateFailed, + "provisioning": DbNodeProvisioningStateProvisioning, + "starting": DbNodeProvisioningStateStarting, + "stopped": DbNodeProvisioningStateStopped, + "stopping": DbNodeProvisioningStateStopping, + "terminated": DbNodeProvisioningStateTerminated, + "terminating": DbNodeProvisioningStateTerminating, + "updating": DbNodeProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DbNodeProvisioningState(input) + return &out, nil +} + +type ResourceProvisioningState string + +const ( + ResourceProvisioningStateCanceled ResourceProvisioningState = "Canceled" + ResourceProvisioningStateFailed ResourceProvisioningState = "Failed" + ResourceProvisioningStateSucceeded ResourceProvisioningState = "Succeeded" +) + +func PossibleValuesForResourceProvisioningState() []string { + return []string{ + string(ResourceProvisioningStateCanceled), + string(ResourceProvisioningStateFailed), + string(ResourceProvisioningStateSucceeded), + } +} + +func (s *ResourceProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResourceProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResourceProvisioningState(input string) (*ResourceProvisioningState, error) { + vals := map[string]ResourceProvisioningState{ + "canceled": ResourceProvisioningStateCanceled, + "failed": ResourceProvisioningStateFailed, + "succeeded": ResourceProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResourceProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/oracledatabase/2024-06-01/dbnodes/id_cloudvmcluster.go b/resource-manager/oracledatabase/2024-06-01/dbnodes/id_cloudvmcluster.go new file mode 100644 index 00000000000..0b78088cce5 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dbnodes/id_cloudvmcluster.go @@ -0,0 +1,130 @@ +package dbnodes + +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(&CloudVMClusterId{}) +} + +var _ resourceids.ResourceId = &CloudVMClusterId{} + +// CloudVMClusterId is a struct representing the Resource ID for a Cloud V M Cluster +type CloudVMClusterId struct { + SubscriptionId string + ResourceGroupName string + CloudVmClusterName string +} + +// NewCloudVMClusterID returns a new CloudVMClusterId struct +func NewCloudVMClusterID(subscriptionId string, resourceGroupName string, cloudVmClusterName string) CloudVMClusterId { + return CloudVMClusterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CloudVmClusterName: cloudVmClusterName, + } +} + +// ParseCloudVMClusterID parses 'input' into a CloudVMClusterId +func ParseCloudVMClusterID(input string) (*CloudVMClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&CloudVMClusterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CloudVMClusterId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCloudVMClusterIDInsensitively parses 'input' case-insensitively into a CloudVMClusterId +// note: this method should only be used for API response data and not user input +func ParseCloudVMClusterIDInsensitively(input string) (*CloudVMClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&CloudVMClusterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CloudVMClusterId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CloudVMClusterId) 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.CloudVmClusterName, ok = input.Parsed["cloudVmClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "cloudVmClusterName", input) + } + + return nil +} + +// ValidateCloudVMClusterID checks that 'input' can be parsed as a Cloud V M Cluster ID +func ValidateCloudVMClusterID(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 := ParseCloudVMClusterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Cloud V M Cluster ID +func (id CloudVMClusterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Oracle.Database/cloudVmClusters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CloudVmClusterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Cloud V M Cluster ID +func (id CloudVMClusterId) 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("staticOracleDatabase", "Oracle.Database", "Oracle.Database"), + resourceids.StaticSegment("staticCloudVmClusters", "cloudVmClusters", "cloudVmClusters"), + resourceids.UserSpecifiedSegment("cloudVmClusterName", "cloudVmClusterValue"), + } +} + +// String returns a human-readable description of this Cloud V M Cluster ID +func (id CloudVMClusterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cloud Vm Cluster Name: %q", id.CloudVmClusterName), + } + return fmt.Sprintf("Cloud V M Cluster (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/oracledatabase/2024-06-01/dbnodes/id_cloudvmcluster_test.go b/resource-manager/oracledatabase/2024-06-01/dbnodes/id_cloudvmcluster_test.go new file mode 100644 index 00000000000..00fd31584af --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dbnodes/id_cloudvmcluster_test.go @@ -0,0 +1,282 @@ +package dbnodes + +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 = &CloudVMClusterId{} + +func TestNewCloudVMClusterID(t *testing.T) { + id := NewCloudVMClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudVmClusterValue") + + 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.CloudVmClusterName != "cloudVmClusterValue" { + t.Fatalf("Expected %q but got %q for Segment 'CloudVmClusterName'", id.CloudVmClusterName, "cloudVmClusterValue") + } +} + +func TestFormatCloudVMClusterID(t *testing.T) { + actual := NewCloudVMClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudVmClusterValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudVmClusters/cloudVmClusterValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCloudVMClusterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CloudVMClusterId + }{ + { + // 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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudVmClusters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudVmClusters/cloudVmClusterValue", + Expected: &CloudVMClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudVmClusterName: "cloudVmClusterValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudVmClusters/cloudVmClusterValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCloudVMClusterID(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.CloudVmClusterName != v.Expected.CloudVmClusterName { + t.Fatalf("Expected %q but got %q for CloudVmClusterName", v.Expected.CloudVmClusterName, actual.CloudVmClusterName) + } + + } +} + +func TestParseCloudVMClusterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CloudVMClusterId + }{ + { + // 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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudVmClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe/cLoUdVmClUsTeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudVmClusters/cloudVmClusterValue", + Expected: &CloudVMClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudVmClusterName: "cloudVmClusterValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudVmClusters/cloudVmClusterValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe/cLoUdVmClUsTeRs/cLoUdVmClUsTeRvAlUe", + Expected: &CloudVMClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CloudVmClusterName: "cLoUdVmClUsTeRvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe/cLoUdVmClUsTeRs/cLoUdVmClUsTeRvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCloudVMClusterIDInsensitively(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.CloudVmClusterName != v.Expected.CloudVmClusterName { + t.Fatalf("Expected %q but got %q for CloudVmClusterName", v.Expected.CloudVmClusterName, actual.CloudVmClusterName) + } + + } +} + +func TestSegmentsForCloudVMClusterId(t *testing.T) { + segments := CloudVMClusterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CloudVMClusterId 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/oracledatabase/2024-06-01/dbnodes/id_dbnode.go b/resource-manager/oracledatabase/2024-06-01/dbnodes/id_dbnode.go new file mode 100644 index 00000000000..e8422bcdfc8 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dbnodes/id_dbnode.go @@ -0,0 +1,139 @@ +package dbnodes + +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(&DbNodeId{}) +} + +var _ resourceids.ResourceId = &DbNodeId{} + +// DbNodeId is a struct representing the Resource ID for a Db Node +type DbNodeId struct { + SubscriptionId string + ResourceGroupName string + CloudVmClusterName string + DbNodeName string +} + +// NewDbNodeID returns a new DbNodeId struct +func NewDbNodeID(subscriptionId string, resourceGroupName string, cloudVmClusterName string, dbNodeName string) DbNodeId { + return DbNodeId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CloudVmClusterName: cloudVmClusterName, + DbNodeName: dbNodeName, + } +} + +// ParseDbNodeID parses 'input' into a DbNodeId +func ParseDbNodeID(input string) (*DbNodeId, error) { + parser := resourceids.NewParserFromResourceIdType(&DbNodeId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DbNodeId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDbNodeIDInsensitively parses 'input' case-insensitively into a DbNodeId +// note: this method should only be used for API response data and not user input +func ParseDbNodeIDInsensitively(input string) (*DbNodeId, error) { + parser := resourceids.NewParserFromResourceIdType(&DbNodeId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DbNodeId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DbNodeId) 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.CloudVmClusterName, ok = input.Parsed["cloudVmClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "cloudVmClusterName", input) + } + + if id.DbNodeName, ok = input.Parsed["dbNodeName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "dbNodeName", input) + } + + return nil +} + +// ValidateDbNodeID checks that 'input' can be parsed as a Db Node ID +func ValidateDbNodeID(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 := ParseDbNodeID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Db Node ID +func (id DbNodeId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Oracle.Database/cloudVmClusters/%s/dbNodes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CloudVmClusterName, id.DbNodeName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Db Node ID +func (id DbNodeId) 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("staticOracleDatabase", "Oracle.Database", "Oracle.Database"), + resourceids.StaticSegment("staticCloudVmClusters", "cloudVmClusters", "cloudVmClusters"), + resourceids.UserSpecifiedSegment("cloudVmClusterName", "cloudVmClusterValue"), + resourceids.StaticSegment("staticDbNodes", "dbNodes", "dbNodes"), + resourceids.UserSpecifiedSegment("dbNodeName", "dbNodeValue"), + } +} + +// String returns a human-readable description of this Db Node ID +func (id DbNodeId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cloud Vm Cluster Name: %q", id.CloudVmClusterName), + fmt.Sprintf("Db Node Name: %q", id.DbNodeName), + } + return fmt.Sprintf("Db Node (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/oracledatabase/2024-06-01/dbnodes/id_dbnode_test.go b/resource-manager/oracledatabase/2024-06-01/dbnodes/id_dbnode_test.go new file mode 100644 index 00000000000..773c92a47ff --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dbnodes/id_dbnode_test.go @@ -0,0 +1,327 @@ +package dbnodes + +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 = &DbNodeId{} + +func TestNewDbNodeID(t *testing.T) { + id := NewDbNodeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudVmClusterValue", "dbNodeValue") + + 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.CloudVmClusterName != "cloudVmClusterValue" { + t.Fatalf("Expected %q but got %q for Segment 'CloudVmClusterName'", id.CloudVmClusterName, "cloudVmClusterValue") + } + + if id.DbNodeName != "dbNodeValue" { + t.Fatalf("Expected %q but got %q for Segment 'DbNodeName'", id.DbNodeName, "dbNodeValue") + } +} + +func TestFormatDbNodeID(t *testing.T) { + actual := NewDbNodeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudVmClusterValue", "dbNodeValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudVmClusters/cloudVmClusterValue/dbNodes/dbNodeValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDbNodeID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DbNodeId + }{ + { + // 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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudVmClusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudVmClusters/cloudVmClusterValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudVmClusters/cloudVmClusterValue/dbNodes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudVmClusters/cloudVmClusterValue/dbNodes/dbNodeValue", + Expected: &DbNodeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudVmClusterName: "cloudVmClusterValue", + DbNodeName: "dbNodeValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudVmClusters/cloudVmClusterValue/dbNodes/dbNodeValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDbNodeID(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.CloudVmClusterName != v.Expected.CloudVmClusterName { + t.Fatalf("Expected %q but got %q for CloudVmClusterName", v.Expected.CloudVmClusterName, actual.CloudVmClusterName) + } + + if actual.DbNodeName != v.Expected.DbNodeName { + t.Fatalf("Expected %q but got %q for DbNodeName", v.Expected.DbNodeName, actual.DbNodeName) + } + + } +} + +func TestParseDbNodeIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DbNodeId + }{ + { + // 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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudVmClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe/cLoUdVmClUsTeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudVmClusters/cloudVmClusterValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe/cLoUdVmClUsTeRs/cLoUdVmClUsTeRvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudVmClusters/cloudVmClusterValue/dbNodes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe/cLoUdVmClUsTeRs/cLoUdVmClUsTeRvAlUe/dBnOdEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudVmClusters/cloudVmClusterValue/dbNodes/dbNodeValue", + Expected: &DbNodeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudVmClusterName: "cloudVmClusterValue", + DbNodeName: "dbNodeValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudVmClusters/cloudVmClusterValue/dbNodes/dbNodeValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe/cLoUdVmClUsTeRs/cLoUdVmClUsTeRvAlUe/dBnOdEs/dBnOdEvAlUe", + Expected: &DbNodeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CloudVmClusterName: "cLoUdVmClUsTeRvAlUe", + DbNodeName: "dBnOdEvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe/cLoUdVmClUsTeRs/cLoUdVmClUsTeRvAlUe/dBnOdEs/dBnOdEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDbNodeIDInsensitively(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.CloudVmClusterName != v.Expected.CloudVmClusterName { + t.Fatalf("Expected %q but got %q for CloudVmClusterName", v.Expected.CloudVmClusterName, actual.CloudVmClusterName) + } + + if actual.DbNodeName != v.Expected.DbNodeName { + t.Fatalf("Expected %q but got %q for DbNodeName", v.Expected.DbNodeName, actual.DbNodeName) + } + + } +} + +func TestSegmentsForDbNodeId(t *testing.T) { + segments := DbNodeId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DbNodeId 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/oracledatabase/2024-06-01/dbnodes/method_action.go b/resource-manager/oracledatabase/2024-06-01/dbnodes/method_action.go new file mode 100644 index 00000000000..5183df9c35c --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dbnodes/method_action.go @@ -0,0 +1,75 @@ +package dbnodes + +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 ActionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *DbNode +} + +// Action ... +func (c DbNodesClient) Action(ctx context.Context, id DbNodeId, input DbNodeAction) (result ActionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/action", 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 +} + +// ActionThenPoll performs Action then polls until it's completed +func (c DbNodesClient) ActionThenPoll(ctx context.Context, id DbNodeId, input DbNodeAction) error { + result, err := c.Action(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Action: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Action: %+v", err) + } + + return nil +} diff --git a/resource-manager/oracledatabase/2024-06-01/dbnodes/method_get.go b/resource-manager/oracledatabase/2024-06-01/dbnodes/method_get.go new file mode 100644 index 00000000000..04a52627245 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dbnodes/method_get.go @@ -0,0 +1,54 @@ +package dbnodes + +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 *DbNode +} + +// Get ... +func (c DbNodesClient) Get(ctx context.Context, id DbNodeId) (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 DbNode + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/oracledatabase/2024-06-01/dbnodes/method_listbycloudvmcluster.go b/resource-manager/oracledatabase/2024-06-01/dbnodes/method_listbycloudvmcluster.go new file mode 100644 index 00000000000..f610bea1c1d --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dbnodes/method_listbycloudvmcluster.go @@ -0,0 +1,105 @@ +package dbnodes + +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 ListByCloudVMClusterOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DbNode +} + +type ListByCloudVMClusterCompleteResult struct { + LatestHttpResponse *http.Response + Items []DbNode +} + +type ListByCloudVMClusterCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByCloudVMClusterCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByCloudVMCluster ... +func (c DbNodesClient) ListByCloudVMCluster(ctx context.Context, id CloudVMClusterId) (result ListByCloudVMClusterOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByCloudVMClusterCustomPager{}, + Path: fmt.Sprintf("%s/dbNodes", 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 *[]DbNode `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByCloudVMClusterComplete retrieves all the results into a single object +func (c DbNodesClient) ListByCloudVMClusterComplete(ctx context.Context, id CloudVMClusterId) (ListByCloudVMClusterCompleteResult, error) { + return c.ListByCloudVMClusterCompleteMatchingPredicate(ctx, id, DbNodeOperationPredicate{}) +} + +// ListByCloudVMClusterCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DbNodesClient) ListByCloudVMClusterCompleteMatchingPredicate(ctx context.Context, id CloudVMClusterId, predicate DbNodeOperationPredicate) (result ListByCloudVMClusterCompleteResult, err error) { + items := make([]DbNode, 0) + + resp, err := c.ListByCloudVMCluster(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByCloudVMClusterCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/oracledatabase/2024-06-01/dbnodes/model_dbnode.go b/resource-manager/oracledatabase/2024-06-01/dbnodes/model_dbnode.go new file mode 100644 index 00000000000..fb43a32d89f --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dbnodes/model_dbnode.go @@ -0,0 +1,16 @@ +package dbnodes + +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 DbNode struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DbNodeProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/dbnodes/model_dbnodeaction.go b/resource-manager/oracledatabase/2024-06-01/dbnodes/model_dbnodeaction.go new file mode 100644 index 00000000000..c73027704e8 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dbnodes/model_dbnodeaction.go @@ -0,0 +1,8 @@ +package dbnodes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DbNodeAction struct { + Action DbNodeActionEnum `json:"action"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/dbnodes/model_dbnodeproperties.go b/resource-manager/oracledatabase/2024-06-01/dbnodes/model_dbnodeproperties.go new file mode 100644 index 00000000000..57c6546805b --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dbnodes/model_dbnodeproperties.go @@ -0,0 +1,72 @@ +package dbnodes + +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 DbNodeProperties struct { + AdditionalDetails *string `json:"additionalDetails,omitempty"` + BackupIPId *string `json:"backupIpId,omitempty"` + BackupVnic2Id *string `json:"backupVnic2Id,omitempty"` + BackupVnicId *string `json:"backupVnicId,omitempty"` + CpuCoreCount *int64 `json:"cpuCoreCount,omitempty"` + DbNodeStorageSizeInGbs *int64 `json:"dbNodeStorageSizeInGbs,omitempty"` + DbServerId *string `json:"dbServerId,omitempty"` + DbSystemId *string `json:"dbSystemId,omitempty"` + FaultDomain *string `json:"faultDomain,omitempty"` + HostIPId *string `json:"hostIpId,omitempty"` + Hostname *string `json:"hostname,omitempty"` + LifecycleDetails *string `json:"lifecycleDetails,omitempty"` + LifecycleState *DbNodeProvisioningState `json:"lifecycleState,omitempty"` + MaintenanceType *DbNodeMaintenanceType `json:"maintenanceType,omitempty"` + MemorySizeInGbs *int64 `json:"memorySizeInGbs,omitempty"` + Ocid *string `json:"ocid,omitempty"` + ProvisioningState *ResourceProvisioningState `json:"provisioningState,omitempty"` + SoftwareStorageSizeInGb *int64 `json:"softwareStorageSizeInGb,omitempty"` + TimeCreated *string `json:"timeCreated,omitempty"` + TimeMaintenanceWindowEnd *string `json:"timeMaintenanceWindowEnd,omitempty"` + TimeMaintenanceWindowStart *string `json:"timeMaintenanceWindowStart,omitempty"` + Vnic2Id *string `json:"vnic2Id,omitempty"` + VnicId *string `json:"vnicId,omitempty"` +} + +func (o *DbNodeProperties) GetTimeCreatedAsTime() (*time.Time, error) { + if o.TimeCreated == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeCreated, "2006-01-02T15:04:05Z07:00") +} + +func (o *DbNodeProperties) SetTimeCreatedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeCreated = &formatted +} + +func (o *DbNodeProperties) GetTimeMaintenanceWindowEndAsTime() (*time.Time, error) { + if o.TimeMaintenanceWindowEnd == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeMaintenanceWindowEnd, "2006-01-02T15:04:05Z07:00") +} + +func (o *DbNodeProperties) SetTimeMaintenanceWindowEndAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeMaintenanceWindowEnd = &formatted +} + +func (o *DbNodeProperties) GetTimeMaintenanceWindowStartAsTime() (*time.Time, error) { + if o.TimeMaintenanceWindowStart == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeMaintenanceWindowStart, "2006-01-02T15:04:05Z07:00") +} + +func (o *DbNodeProperties) SetTimeMaintenanceWindowStartAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeMaintenanceWindowStart = &formatted +} diff --git a/resource-manager/oracledatabase/2024-06-01/dbnodes/predicates.go b/resource-manager/oracledatabase/2024-06-01/dbnodes/predicates.go new file mode 100644 index 00000000000..d8b48325d58 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dbnodes/predicates.go @@ -0,0 +1,27 @@ +package dbnodes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DbNodeOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p DbNodeOperationPredicate) Matches(input DbNode) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/oracledatabase/2024-06-01/dbnodes/version.go b/resource-manager/oracledatabase/2024-06-01/dbnodes/version.go new file mode 100644 index 00000000000..9e4fa8962fb --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dbnodes/version.go @@ -0,0 +1,12 @@ +package dbnodes + +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-06-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/dbnodes/%s", defaultApiVersion) +} diff --git a/resource-manager/oracledatabase/2024-06-01/dbservers/README.md b/resource-manager/oracledatabase/2024-06-01/dbservers/README.md new file mode 100644 index 00000000000..d49cab85097 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dbservers/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/dbservers` Documentation + +The `dbservers` SDK allows for interaction with the Azure Resource Manager Service `oracledatabase` (API Version `2024-06-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/oracledatabase/2024-06-01/dbservers" +``` + + +### Client Initialization + +```go +client := dbservers.NewDbServersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DbServersClient.Get` + +```go +ctx := context.TODO() +id := dbservers.NewDbServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudExadataInfrastructureValue", "dbServerValue") + +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: `DbServersClient.ListByCloudExadataInfrastructure` + +```go +ctx := context.TODO() +id := dbservers.NewCloudExadataInfrastructureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudExadataInfrastructureValue") + +// alternatively `client.ListByCloudExadataInfrastructure(ctx, id)` can be used to do batched pagination +items, err := client.ListByCloudExadataInfrastructureComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/oracledatabase/2024-06-01/dbservers/client.go b/resource-manager/oracledatabase/2024-06-01/dbservers/client.go new file mode 100644 index 00000000000..76eb2495be8 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dbservers/client.go @@ -0,0 +1,26 @@ +package dbservers + +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 DbServersClient struct { + Client *resourcemanager.Client +} + +func NewDbServersClientWithBaseURI(sdkApi sdkEnv.Api) (*DbServersClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "dbservers", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DbServersClient: %+v", err) + } + + return &DbServersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/oracledatabase/2024-06-01/dbservers/constants.go b/resource-manager/oracledatabase/2024-06-01/dbservers/constants.go new file mode 100644 index 00000000000..16d6ef78fb2 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dbservers/constants.go @@ -0,0 +1,154 @@ +package dbservers + +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 DbServerPatchingStatus string + +const ( + DbServerPatchingStatusComplete DbServerPatchingStatus = "Complete" + DbServerPatchingStatusFailed DbServerPatchingStatus = "Failed" + DbServerPatchingStatusMaintenanceInProgress DbServerPatchingStatus = "MaintenanceInProgress" + DbServerPatchingStatusScheduled DbServerPatchingStatus = "Scheduled" +) + +func PossibleValuesForDbServerPatchingStatus() []string { + return []string{ + string(DbServerPatchingStatusComplete), + string(DbServerPatchingStatusFailed), + string(DbServerPatchingStatusMaintenanceInProgress), + string(DbServerPatchingStatusScheduled), + } +} + +func (s *DbServerPatchingStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDbServerPatchingStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDbServerPatchingStatus(input string) (*DbServerPatchingStatus, error) { + vals := map[string]DbServerPatchingStatus{ + "complete": DbServerPatchingStatusComplete, + "failed": DbServerPatchingStatusFailed, + "maintenanceinprogress": DbServerPatchingStatusMaintenanceInProgress, + "scheduled": DbServerPatchingStatusScheduled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DbServerPatchingStatus(input) + return &out, nil +} + +type DbServerProvisioningState string + +const ( + DbServerProvisioningStateAvailable DbServerProvisioningState = "Available" + DbServerProvisioningStateCreating DbServerProvisioningState = "Creating" + DbServerProvisioningStateDeleted DbServerProvisioningState = "Deleted" + DbServerProvisioningStateDeleting DbServerProvisioningState = "Deleting" + DbServerProvisioningStateMaintenanceInProgress DbServerProvisioningState = "MaintenanceInProgress" + DbServerProvisioningStateUnavailable DbServerProvisioningState = "Unavailable" +) + +func PossibleValuesForDbServerProvisioningState() []string { + return []string{ + string(DbServerProvisioningStateAvailable), + string(DbServerProvisioningStateCreating), + string(DbServerProvisioningStateDeleted), + string(DbServerProvisioningStateDeleting), + string(DbServerProvisioningStateMaintenanceInProgress), + string(DbServerProvisioningStateUnavailable), + } +} + +func (s *DbServerProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDbServerProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDbServerProvisioningState(input string) (*DbServerProvisioningState, error) { + vals := map[string]DbServerProvisioningState{ + "available": DbServerProvisioningStateAvailable, + "creating": DbServerProvisioningStateCreating, + "deleted": DbServerProvisioningStateDeleted, + "deleting": DbServerProvisioningStateDeleting, + "maintenanceinprogress": DbServerProvisioningStateMaintenanceInProgress, + "unavailable": DbServerProvisioningStateUnavailable, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DbServerProvisioningState(input) + return &out, nil +} + +type ResourceProvisioningState string + +const ( + ResourceProvisioningStateCanceled ResourceProvisioningState = "Canceled" + ResourceProvisioningStateFailed ResourceProvisioningState = "Failed" + ResourceProvisioningStateSucceeded ResourceProvisioningState = "Succeeded" +) + +func PossibleValuesForResourceProvisioningState() []string { + return []string{ + string(ResourceProvisioningStateCanceled), + string(ResourceProvisioningStateFailed), + string(ResourceProvisioningStateSucceeded), + } +} + +func (s *ResourceProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResourceProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResourceProvisioningState(input string) (*ResourceProvisioningState, error) { + vals := map[string]ResourceProvisioningState{ + "canceled": ResourceProvisioningStateCanceled, + "failed": ResourceProvisioningStateFailed, + "succeeded": ResourceProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResourceProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/oracledatabase/2024-06-01/dbservers/id_cloudexadatainfrastructure.go b/resource-manager/oracledatabase/2024-06-01/dbservers/id_cloudexadatainfrastructure.go new file mode 100644 index 00000000000..3507447b71e --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dbservers/id_cloudexadatainfrastructure.go @@ -0,0 +1,130 @@ +package dbservers + +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(&CloudExadataInfrastructureId{}) +} + +var _ resourceids.ResourceId = &CloudExadataInfrastructureId{} + +// CloudExadataInfrastructureId is a struct representing the Resource ID for a Cloud Exadata Infrastructure +type CloudExadataInfrastructureId struct { + SubscriptionId string + ResourceGroupName string + CloudExadataInfrastructureName string +} + +// NewCloudExadataInfrastructureID returns a new CloudExadataInfrastructureId struct +func NewCloudExadataInfrastructureID(subscriptionId string, resourceGroupName string, cloudExadataInfrastructureName string) CloudExadataInfrastructureId { + return CloudExadataInfrastructureId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CloudExadataInfrastructureName: cloudExadataInfrastructureName, + } +} + +// ParseCloudExadataInfrastructureID parses 'input' into a CloudExadataInfrastructureId +func ParseCloudExadataInfrastructureID(input string) (*CloudExadataInfrastructureId, error) { + parser := resourceids.NewParserFromResourceIdType(&CloudExadataInfrastructureId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CloudExadataInfrastructureId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCloudExadataInfrastructureIDInsensitively parses 'input' case-insensitively into a CloudExadataInfrastructureId +// note: this method should only be used for API response data and not user input +func ParseCloudExadataInfrastructureIDInsensitively(input string) (*CloudExadataInfrastructureId, error) { + parser := resourceids.NewParserFromResourceIdType(&CloudExadataInfrastructureId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CloudExadataInfrastructureId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CloudExadataInfrastructureId) 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.CloudExadataInfrastructureName, ok = input.Parsed["cloudExadataInfrastructureName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "cloudExadataInfrastructureName", input) + } + + return nil +} + +// ValidateCloudExadataInfrastructureID checks that 'input' can be parsed as a Cloud Exadata Infrastructure ID +func ValidateCloudExadataInfrastructureID(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 := ParseCloudExadataInfrastructureID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Cloud Exadata Infrastructure ID +func (id CloudExadataInfrastructureId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Oracle.Database/cloudExadataInfrastructures/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CloudExadataInfrastructureName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Cloud Exadata Infrastructure ID +func (id CloudExadataInfrastructureId) 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("staticOracleDatabase", "Oracle.Database", "Oracle.Database"), + resourceids.StaticSegment("staticCloudExadataInfrastructures", "cloudExadataInfrastructures", "cloudExadataInfrastructures"), + resourceids.UserSpecifiedSegment("cloudExadataInfrastructureName", "cloudExadataInfrastructureValue"), + } +} + +// String returns a human-readable description of this Cloud Exadata Infrastructure ID +func (id CloudExadataInfrastructureId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cloud Exadata Infrastructure Name: %q", id.CloudExadataInfrastructureName), + } + return fmt.Sprintf("Cloud Exadata Infrastructure (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/oracledatabase/2024-06-01/dbservers/id_cloudexadatainfrastructure_test.go b/resource-manager/oracledatabase/2024-06-01/dbservers/id_cloudexadatainfrastructure_test.go new file mode 100644 index 00000000000..71e94f2fa49 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dbservers/id_cloudexadatainfrastructure_test.go @@ -0,0 +1,282 @@ +package dbservers + +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 = &CloudExadataInfrastructureId{} + +func TestNewCloudExadataInfrastructureID(t *testing.T) { + id := NewCloudExadataInfrastructureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudExadataInfrastructureValue") + + 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.CloudExadataInfrastructureName != "cloudExadataInfrastructureValue" { + t.Fatalf("Expected %q but got %q for Segment 'CloudExadataInfrastructureName'", id.CloudExadataInfrastructureName, "cloudExadataInfrastructureValue") + } +} + +func TestFormatCloudExadataInfrastructureID(t *testing.T) { + actual := NewCloudExadataInfrastructureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudExadataInfrastructureValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudExadataInfrastructures/cloudExadataInfrastructureValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCloudExadataInfrastructureID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CloudExadataInfrastructureId + }{ + { + // 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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudExadataInfrastructures", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudExadataInfrastructures/cloudExadataInfrastructureValue", + Expected: &CloudExadataInfrastructureId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudExadataInfrastructureName: "cloudExadataInfrastructureValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudExadataInfrastructures/cloudExadataInfrastructureValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCloudExadataInfrastructureID(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.CloudExadataInfrastructureName != v.Expected.CloudExadataInfrastructureName { + t.Fatalf("Expected %q but got %q for CloudExadataInfrastructureName", v.Expected.CloudExadataInfrastructureName, actual.CloudExadataInfrastructureName) + } + + } +} + +func TestParseCloudExadataInfrastructureIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CloudExadataInfrastructureId + }{ + { + // 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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudExadataInfrastructures", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe/cLoUdExAdAtAiNfRaStRuCtUrEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudExadataInfrastructures/cloudExadataInfrastructureValue", + Expected: &CloudExadataInfrastructureId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudExadataInfrastructureName: "cloudExadataInfrastructureValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudExadataInfrastructures/cloudExadataInfrastructureValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe/cLoUdExAdAtAiNfRaStRuCtUrEs/cLoUdExAdAtAiNfRaStRuCtUrEvAlUe", + Expected: &CloudExadataInfrastructureId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CloudExadataInfrastructureName: "cLoUdExAdAtAiNfRaStRuCtUrEvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe/cLoUdExAdAtAiNfRaStRuCtUrEs/cLoUdExAdAtAiNfRaStRuCtUrEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCloudExadataInfrastructureIDInsensitively(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.CloudExadataInfrastructureName != v.Expected.CloudExadataInfrastructureName { + t.Fatalf("Expected %q but got %q for CloudExadataInfrastructureName", v.Expected.CloudExadataInfrastructureName, actual.CloudExadataInfrastructureName) + } + + } +} + +func TestSegmentsForCloudExadataInfrastructureId(t *testing.T) { + segments := CloudExadataInfrastructureId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CloudExadataInfrastructureId 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/oracledatabase/2024-06-01/dbservers/id_dbserver.go b/resource-manager/oracledatabase/2024-06-01/dbservers/id_dbserver.go new file mode 100644 index 00000000000..6fa4f9993f1 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dbservers/id_dbserver.go @@ -0,0 +1,139 @@ +package dbservers + +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(&DbServerId{}) +} + +var _ resourceids.ResourceId = &DbServerId{} + +// DbServerId is a struct representing the Resource ID for a Db Server +type DbServerId struct { + SubscriptionId string + ResourceGroupName string + CloudExadataInfrastructureName string + DbServerName string +} + +// NewDbServerID returns a new DbServerId struct +func NewDbServerID(subscriptionId string, resourceGroupName string, cloudExadataInfrastructureName string, dbServerName string) DbServerId { + return DbServerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CloudExadataInfrastructureName: cloudExadataInfrastructureName, + DbServerName: dbServerName, + } +} + +// ParseDbServerID parses 'input' into a DbServerId +func ParseDbServerID(input string) (*DbServerId, error) { + parser := resourceids.NewParserFromResourceIdType(&DbServerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DbServerId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDbServerIDInsensitively parses 'input' case-insensitively into a DbServerId +// note: this method should only be used for API response data and not user input +func ParseDbServerIDInsensitively(input string) (*DbServerId, error) { + parser := resourceids.NewParserFromResourceIdType(&DbServerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DbServerId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DbServerId) 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.CloudExadataInfrastructureName, ok = input.Parsed["cloudExadataInfrastructureName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "cloudExadataInfrastructureName", input) + } + + if id.DbServerName, ok = input.Parsed["dbServerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "dbServerName", input) + } + + return nil +} + +// ValidateDbServerID checks that 'input' can be parsed as a Db Server ID +func ValidateDbServerID(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 := ParseDbServerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Db Server ID +func (id DbServerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Oracle.Database/cloudExadataInfrastructures/%s/dbServers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CloudExadataInfrastructureName, id.DbServerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Db Server ID +func (id DbServerId) 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("staticOracleDatabase", "Oracle.Database", "Oracle.Database"), + resourceids.StaticSegment("staticCloudExadataInfrastructures", "cloudExadataInfrastructures", "cloudExadataInfrastructures"), + resourceids.UserSpecifiedSegment("cloudExadataInfrastructureName", "cloudExadataInfrastructureValue"), + resourceids.StaticSegment("staticDbServers", "dbServers", "dbServers"), + resourceids.UserSpecifiedSegment("dbServerName", "dbServerValue"), + } +} + +// String returns a human-readable description of this Db Server ID +func (id DbServerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cloud Exadata Infrastructure Name: %q", id.CloudExadataInfrastructureName), + fmt.Sprintf("Db Server Name: %q", id.DbServerName), + } + return fmt.Sprintf("Db Server (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/oracledatabase/2024-06-01/dbservers/id_dbserver_test.go b/resource-manager/oracledatabase/2024-06-01/dbservers/id_dbserver_test.go new file mode 100644 index 00000000000..8d5fc7a0a78 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dbservers/id_dbserver_test.go @@ -0,0 +1,327 @@ +package dbservers + +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 = &DbServerId{} + +func TestNewDbServerID(t *testing.T) { + id := NewDbServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudExadataInfrastructureValue", "dbServerValue") + + 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.CloudExadataInfrastructureName != "cloudExadataInfrastructureValue" { + t.Fatalf("Expected %q but got %q for Segment 'CloudExadataInfrastructureName'", id.CloudExadataInfrastructureName, "cloudExadataInfrastructureValue") + } + + if id.DbServerName != "dbServerValue" { + t.Fatalf("Expected %q but got %q for Segment 'DbServerName'", id.DbServerName, "dbServerValue") + } +} + +func TestFormatDbServerID(t *testing.T) { + actual := NewDbServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudExadataInfrastructureValue", "dbServerValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudExadataInfrastructures/cloudExadataInfrastructureValue/dbServers/dbServerValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDbServerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DbServerId + }{ + { + // 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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudExadataInfrastructures", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudExadataInfrastructures/cloudExadataInfrastructureValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudExadataInfrastructures/cloudExadataInfrastructureValue/dbServers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudExadataInfrastructures/cloudExadataInfrastructureValue/dbServers/dbServerValue", + Expected: &DbServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudExadataInfrastructureName: "cloudExadataInfrastructureValue", + DbServerName: "dbServerValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudExadataInfrastructures/cloudExadataInfrastructureValue/dbServers/dbServerValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDbServerID(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.CloudExadataInfrastructureName != v.Expected.CloudExadataInfrastructureName { + t.Fatalf("Expected %q but got %q for CloudExadataInfrastructureName", v.Expected.CloudExadataInfrastructureName, actual.CloudExadataInfrastructureName) + } + + if actual.DbServerName != v.Expected.DbServerName { + t.Fatalf("Expected %q but got %q for DbServerName", v.Expected.DbServerName, actual.DbServerName) + } + + } +} + +func TestParseDbServerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DbServerId + }{ + { + // 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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudExadataInfrastructures", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe/cLoUdExAdAtAiNfRaStRuCtUrEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudExadataInfrastructures/cloudExadataInfrastructureValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe/cLoUdExAdAtAiNfRaStRuCtUrEs/cLoUdExAdAtAiNfRaStRuCtUrEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudExadataInfrastructures/cloudExadataInfrastructureValue/dbServers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe/cLoUdExAdAtAiNfRaStRuCtUrEs/cLoUdExAdAtAiNfRaStRuCtUrEvAlUe/dBsErVeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudExadataInfrastructures/cloudExadataInfrastructureValue/dbServers/dbServerValue", + Expected: &DbServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudExadataInfrastructureName: "cloudExadataInfrastructureValue", + DbServerName: "dbServerValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudExadataInfrastructures/cloudExadataInfrastructureValue/dbServers/dbServerValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe/cLoUdExAdAtAiNfRaStRuCtUrEs/cLoUdExAdAtAiNfRaStRuCtUrEvAlUe/dBsErVeRs/dBsErVeRvAlUe", + Expected: &DbServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CloudExadataInfrastructureName: "cLoUdExAdAtAiNfRaStRuCtUrEvAlUe", + DbServerName: "dBsErVeRvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe/cLoUdExAdAtAiNfRaStRuCtUrEs/cLoUdExAdAtAiNfRaStRuCtUrEvAlUe/dBsErVeRs/dBsErVeRvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDbServerIDInsensitively(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.CloudExadataInfrastructureName != v.Expected.CloudExadataInfrastructureName { + t.Fatalf("Expected %q but got %q for CloudExadataInfrastructureName", v.Expected.CloudExadataInfrastructureName, actual.CloudExadataInfrastructureName) + } + + if actual.DbServerName != v.Expected.DbServerName { + t.Fatalf("Expected %q but got %q for DbServerName", v.Expected.DbServerName, actual.DbServerName) + } + + } +} + +func TestSegmentsForDbServerId(t *testing.T) { + segments := DbServerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DbServerId 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/oracledatabase/2024-06-01/dbservers/method_get.go b/resource-manager/oracledatabase/2024-06-01/dbservers/method_get.go new file mode 100644 index 00000000000..acb90a24d7e --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dbservers/method_get.go @@ -0,0 +1,54 @@ +package dbservers + +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 *DbServer +} + +// Get ... +func (c DbServersClient) Get(ctx context.Context, id DbServerId) (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 DbServer + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/oracledatabase/2024-06-01/dbservers/method_listbycloudexadatainfrastructure.go b/resource-manager/oracledatabase/2024-06-01/dbservers/method_listbycloudexadatainfrastructure.go new file mode 100644 index 00000000000..7440cdef40a --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dbservers/method_listbycloudexadatainfrastructure.go @@ -0,0 +1,105 @@ +package dbservers + +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 ListByCloudExadataInfrastructureOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DbServer +} + +type ListByCloudExadataInfrastructureCompleteResult struct { + LatestHttpResponse *http.Response + Items []DbServer +} + +type ListByCloudExadataInfrastructureCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByCloudExadataInfrastructureCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByCloudExadataInfrastructure ... +func (c DbServersClient) ListByCloudExadataInfrastructure(ctx context.Context, id CloudExadataInfrastructureId) (result ListByCloudExadataInfrastructureOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByCloudExadataInfrastructureCustomPager{}, + Path: fmt.Sprintf("%s/dbServers", 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 *[]DbServer `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByCloudExadataInfrastructureComplete retrieves all the results into a single object +func (c DbServersClient) ListByCloudExadataInfrastructureComplete(ctx context.Context, id CloudExadataInfrastructureId) (ListByCloudExadataInfrastructureCompleteResult, error) { + return c.ListByCloudExadataInfrastructureCompleteMatchingPredicate(ctx, id, DbServerOperationPredicate{}) +} + +// ListByCloudExadataInfrastructureCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DbServersClient) ListByCloudExadataInfrastructureCompleteMatchingPredicate(ctx context.Context, id CloudExadataInfrastructureId, predicate DbServerOperationPredicate) (result ListByCloudExadataInfrastructureCompleteResult, err error) { + items := make([]DbServer, 0) + + resp, err := c.ListByCloudExadataInfrastructure(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByCloudExadataInfrastructureCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/oracledatabase/2024-06-01/dbservers/model_dbserver.go b/resource-manager/oracledatabase/2024-06-01/dbservers/model_dbserver.go new file mode 100644 index 00000000000..a88571f8613 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dbservers/model_dbserver.go @@ -0,0 +1,16 @@ +package dbservers + +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 DbServer struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DbServerProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/dbservers/model_dbserverpatchingdetails.go b/resource-manager/oracledatabase/2024-06-01/dbservers/model_dbserverpatchingdetails.go new file mode 100644 index 00000000000..5bb65512c64 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dbservers/model_dbserverpatchingdetails.go @@ -0,0 +1,41 @@ +package dbservers + +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 DbServerPatchingDetails struct { + EstimatedPatchDuration *int64 `json:"estimatedPatchDuration,omitempty"` + PatchingStatus *DbServerPatchingStatus `json:"patchingStatus,omitempty"` + TimePatchingEnded *string `json:"timePatchingEnded,omitempty"` + TimePatchingStarted *string `json:"timePatchingStarted,omitempty"` +} + +func (o *DbServerPatchingDetails) GetTimePatchingEndedAsTime() (*time.Time, error) { + if o.TimePatchingEnded == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimePatchingEnded, "2006-01-02T15:04:05Z07:00") +} + +func (o *DbServerPatchingDetails) SetTimePatchingEndedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimePatchingEnded = &formatted +} + +func (o *DbServerPatchingDetails) GetTimePatchingStartedAsTime() (*time.Time, error) { + if o.TimePatchingStarted == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimePatchingStarted, "2006-01-02T15:04:05Z07:00") +} + +func (o *DbServerPatchingDetails) SetTimePatchingStartedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimePatchingStarted = &formatted +} diff --git a/resource-manager/oracledatabase/2024-06-01/dbservers/model_dbserverproperties.go b/resource-manager/oracledatabase/2024-06-01/dbservers/model_dbserverproperties.go new file mode 100644 index 00000000000..39df4cede8c --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dbservers/model_dbserverproperties.go @@ -0,0 +1,45 @@ +package dbservers + +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 DbServerProperties struct { + AutonomousVMClusterIds *[]string `json:"autonomousVmClusterIds,omitempty"` + AutonomousVirtualMachineIds *[]string `json:"autonomousVirtualMachineIds,omitempty"` + CompartmentId *string `json:"compartmentId,omitempty"` + CpuCoreCount *int64 `json:"cpuCoreCount,omitempty"` + DbNodeIds *[]string `json:"dbNodeIds,omitempty"` + DbNodeStorageSizeInGbs *int64 `json:"dbNodeStorageSizeInGbs,omitempty"` + DbServerPatchingDetails *DbServerPatchingDetails `json:"dbServerPatchingDetails,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + ExadataInfrastructureId *string `json:"exadataInfrastructureId,omitempty"` + LifecycleDetails *string `json:"lifecycleDetails,omitempty"` + LifecycleState *DbServerProvisioningState `json:"lifecycleState,omitempty"` + MaxCPUCount *int64 `json:"maxCpuCount,omitempty"` + MaxDbNodeStorageInGbs *int64 `json:"maxDbNodeStorageInGbs,omitempty"` + MaxMemoryInGbs *int64 `json:"maxMemoryInGbs,omitempty"` + MemorySizeInGbs *int64 `json:"memorySizeInGbs,omitempty"` + Ocid *string `json:"ocid,omitempty"` + ProvisioningState *ResourceProvisioningState `json:"provisioningState,omitempty"` + Shape *string `json:"shape,omitempty"` + TimeCreated *string `json:"timeCreated,omitempty"` + VMClusterIds *[]string `json:"vmClusterIds,omitempty"` +} + +func (o *DbServerProperties) GetTimeCreatedAsTime() (*time.Time, error) { + if o.TimeCreated == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeCreated, "2006-01-02T15:04:05Z07:00") +} + +func (o *DbServerProperties) SetTimeCreatedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeCreated = &formatted +} diff --git a/resource-manager/oracledatabase/2024-06-01/dbservers/predicates.go b/resource-manager/oracledatabase/2024-06-01/dbservers/predicates.go new file mode 100644 index 00000000000..dfcc35d7ef6 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dbservers/predicates.go @@ -0,0 +1,27 @@ +package dbservers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DbServerOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p DbServerOperationPredicate) Matches(input DbServer) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/oracledatabase/2024-06-01/dbservers/version.go b/resource-manager/oracledatabase/2024-06-01/dbservers/version.go new file mode 100644 index 00000000000..f369bd54279 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dbservers/version.go @@ -0,0 +1,12 @@ +package dbservers + +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-06-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/dbservers/%s", defaultApiVersion) +} diff --git a/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/README.md b/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/README.md new file mode 100644 index 00000000000..23f0eac9ceb --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/dbsystemshapes` Documentation + +The `dbsystemshapes` SDK allows for interaction with the Azure Resource Manager Service `oracledatabase` (API Version `2024-06-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/oracledatabase/2024-06-01/dbsystemshapes" +``` + + +### Client Initialization + +```go +client := dbsystemshapes.NewDbSystemShapesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DbSystemShapesClient.Get` + +```go +ctx := context.TODO() +id := dbsystemshapes.NewDbSystemShapeID("12345678-1234-9876-4563-123456789012", "locationValue", "dbSystemShapeValue") + +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: `DbSystemShapesClient.ListByLocation` + +```go +ctx := context.TODO() +id := dbsystemshapes.NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + +// alternatively `client.ListByLocation(ctx, id)` can be used to do batched pagination +items, err := client.ListByLocationComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/client.go b/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/client.go new file mode 100644 index 00000000000..5b0f0522f52 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/client.go @@ -0,0 +1,26 @@ +package dbsystemshapes + +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 DbSystemShapesClient struct { + Client *resourcemanager.Client +} + +func NewDbSystemShapesClientWithBaseURI(sdkApi sdkEnv.Api) (*DbSystemShapesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "dbsystemshapes", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DbSystemShapesClient: %+v", err) + } + + return &DbSystemShapesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/id_dbsystemshape.go b/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/id_dbsystemshape.go new file mode 100644 index 00000000000..759b456b8bb --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/id_dbsystemshape.go @@ -0,0 +1,130 @@ +package dbsystemshapes + +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(&DbSystemShapeId{}) +} + +var _ resourceids.ResourceId = &DbSystemShapeId{} + +// DbSystemShapeId is a struct representing the Resource ID for a Db System Shape +type DbSystemShapeId struct { + SubscriptionId string + LocationName string + DbSystemShapeName string +} + +// NewDbSystemShapeID returns a new DbSystemShapeId struct +func NewDbSystemShapeID(subscriptionId string, locationName string, dbSystemShapeName string) DbSystemShapeId { + return DbSystemShapeId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + DbSystemShapeName: dbSystemShapeName, + } +} + +// ParseDbSystemShapeID parses 'input' into a DbSystemShapeId +func ParseDbSystemShapeID(input string) (*DbSystemShapeId, error) { + parser := resourceids.NewParserFromResourceIdType(&DbSystemShapeId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DbSystemShapeId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDbSystemShapeIDInsensitively parses 'input' case-insensitively into a DbSystemShapeId +// note: this method should only be used for API response data and not user input +func ParseDbSystemShapeIDInsensitively(input string) (*DbSystemShapeId, error) { + parser := resourceids.NewParserFromResourceIdType(&DbSystemShapeId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DbSystemShapeId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DbSystemShapeId) 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) + } + + if id.DbSystemShapeName, ok = input.Parsed["dbSystemShapeName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "dbSystemShapeName", input) + } + + return nil +} + +// ValidateDbSystemShapeID checks that 'input' can be parsed as a Db System Shape ID +func ValidateDbSystemShapeID(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 := ParseDbSystemShapeID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Db System Shape ID +func (id DbSystemShapeId) ID() string { + fmtString := "/subscriptions/%s/providers/Oracle.Database/locations/%s/dbSystemShapes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName, id.DbSystemShapeName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Db System Shape ID +func (id DbSystemShapeId) 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("staticOracleDatabase", "Oracle.Database", "Oracle.Database"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationValue"), + resourceids.StaticSegment("staticDbSystemShapes", "dbSystemShapes", "dbSystemShapes"), + resourceids.UserSpecifiedSegment("dbSystemShapeName", "dbSystemShapeValue"), + } +} + +// String returns a human-readable description of this Db System Shape ID +func (id DbSystemShapeId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + fmt.Sprintf("Db System Shape Name: %q", id.DbSystemShapeName), + } + return fmt.Sprintf("Db System Shape (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/id_dbsystemshape_test.go b/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/id_dbsystemshape_test.go new file mode 100644 index 00000000000..916983aac40 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/id_dbsystemshape_test.go @@ -0,0 +1,282 @@ +package dbsystemshapes + +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 = &DbSystemShapeId{} + +func TestNewDbSystemShapeID(t *testing.T) { + id := NewDbSystemShapeID("12345678-1234-9876-4563-123456789012", "locationValue", "dbSystemShapeValue") + + 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") + } + + if id.DbSystemShapeName != "dbSystemShapeValue" { + t.Fatalf("Expected %q but got %q for Segment 'DbSystemShapeName'", id.DbSystemShapeName, "dbSystemShapeValue") + } +} + +func TestFormatDbSystemShapeID(t *testing.T) { + actual := NewDbSystemShapeID("12345678-1234-9876-4563-123456789012", "locationValue", "dbSystemShapeValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/dbSystemShapes/dbSystemShapeValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDbSystemShapeID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DbSystemShapeId + }{ + { + // 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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/dbSystemShapes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/dbSystemShapes/dbSystemShapeValue", + Expected: &DbSystemShapeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + DbSystemShapeName: "dbSystemShapeValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/dbSystemShapes/dbSystemShapeValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDbSystemShapeID(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) + } + + if actual.DbSystemShapeName != v.Expected.DbSystemShapeName { + t.Fatalf("Expected %q but got %q for DbSystemShapeName", v.Expected.DbSystemShapeName, actual.DbSystemShapeName) + } + + } +} + +func TestParseDbSystemShapeIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DbSystemShapeId + }{ + { + // 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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs/lOcAtIoNvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/dbSystemShapes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs/lOcAtIoNvAlUe/dBsYsTeMsHaPeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/dbSystemShapes/dbSystemShapeValue", + Expected: &DbSystemShapeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + DbSystemShapeName: "dbSystemShapeValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/dbSystemShapes/dbSystemShapeValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs/lOcAtIoNvAlUe/dBsYsTeMsHaPeS/dBsYsTeMsHaPeVaLuE", + Expected: &DbSystemShapeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNvAlUe", + DbSystemShapeName: "dBsYsTeMsHaPeVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs/lOcAtIoNvAlUe/dBsYsTeMsHaPeS/dBsYsTeMsHaPeVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDbSystemShapeIDInsensitively(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) + } + + if actual.DbSystemShapeName != v.Expected.DbSystemShapeName { + t.Fatalf("Expected %q but got %q for DbSystemShapeName", v.Expected.DbSystemShapeName, actual.DbSystemShapeName) + } + + } +} + +func TestSegmentsForDbSystemShapeId(t *testing.T) { + segments := DbSystemShapeId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DbSystemShapeId 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/oracledatabase/2024-06-01/dbsystemshapes/id_location.go b/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/id_location.go new file mode 100644 index 00000000000..fad455455f4 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/id_location.go @@ -0,0 +1,121 @@ +package dbsystemshapes + +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/Oracle.Database/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("staticOracleDatabase", "Oracle.Database", "Oracle.Database"), + 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/oracledatabase/2024-06-01/dbsystemshapes/id_location_test.go b/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/id_location_test.go new file mode 100644 index 00000000000..39f3082fd27 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/id_location_test.go @@ -0,0 +1,237 @@ +package dbsystemshapes + +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/Oracle.Database/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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/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/Oracle.Database/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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/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/Oracle.Database/locations/locationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/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/oRaClE.DaTaBaSe/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/oracledatabase/2024-06-01/dbsystemshapes/method_get.go b/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/method_get.go new file mode 100644 index 00000000000..fa82bf6c83c --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/method_get.go @@ -0,0 +1,54 @@ +package dbsystemshapes + +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 *DbSystemShape +} + +// Get ... +func (c DbSystemShapesClient) Get(ctx context.Context, id DbSystemShapeId) (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 DbSystemShape + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/method_listbylocation.go b/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/method_listbylocation.go new file mode 100644 index 00000000000..c96b2770032 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/method_listbylocation.go @@ -0,0 +1,105 @@ +package dbsystemshapes + +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 ListByLocationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DbSystemShape +} + +type ListByLocationCompleteResult struct { + LatestHttpResponse *http.Response + Items []DbSystemShape +} + +type ListByLocationCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByLocationCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByLocation ... +func (c DbSystemShapesClient) ListByLocation(ctx context.Context, id LocationId) (result ListByLocationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByLocationCustomPager{}, + Path: fmt.Sprintf("%s/dbSystemShapes", 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 *[]DbSystemShape `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByLocationComplete retrieves all the results into a single object +func (c DbSystemShapesClient) ListByLocationComplete(ctx context.Context, id LocationId) (ListByLocationCompleteResult, error) { + return c.ListByLocationCompleteMatchingPredicate(ctx, id, DbSystemShapeOperationPredicate{}) +} + +// ListByLocationCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DbSystemShapesClient) ListByLocationCompleteMatchingPredicate(ctx context.Context, id LocationId, predicate DbSystemShapeOperationPredicate) (result ListByLocationCompleteResult, err error) { + items := make([]DbSystemShape, 0) + + resp, err := c.ListByLocation(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByLocationCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/model_dbsystemshape.go b/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/model_dbsystemshape.go new file mode 100644 index 00000000000..69813657351 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/model_dbsystemshape.go @@ -0,0 +1,16 @@ +package dbsystemshapes + +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 DbSystemShape struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DbSystemShapeProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/model_dbsystemshapeproperties.go b/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/model_dbsystemshapeproperties.go new file mode 100644 index 00000000000..a7642317091 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/model_dbsystemshapeproperties.go @@ -0,0 +1,27 @@ +package dbsystemshapes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DbSystemShapeProperties struct { + AvailableCoreCount *int64 `json:"availableCoreCount,omitempty"` + AvailableCoreCountPerNode *int64 `json:"availableCoreCountPerNode,omitempty"` + AvailableDataStorageInTbs *int64 `json:"availableDataStorageInTbs,omitempty"` + AvailableDataStoragePerServerInTbs *float64 `json:"availableDataStoragePerServerInTbs,omitempty"` + AvailableDbNodePerNodeInGbs *int64 `json:"availableDbNodePerNodeInGbs,omitempty"` + AvailableDbNodeStorageInGbs *int64 `json:"availableDbNodeStorageInGbs,omitempty"` + AvailableMemoryInGbs *int64 `json:"availableMemoryInGbs,omitempty"` + AvailableMemoryPerNodeInGbs *int64 `json:"availableMemoryPerNodeInGbs,omitempty"` + CoreCountIncrement *int64 `json:"coreCountIncrement,omitempty"` + MaxStorageCount *int64 `json:"maxStorageCount,omitempty"` + MaximumNodeCount *int64 `json:"maximumNodeCount,omitempty"` + MinCoreCountPerNode *int64 `json:"minCoreCountPerNode,omitempty"` + MinDataStorageInTbs *int64 `json:"minDataStorageInTbs,omitempty"` + MinDbNodeStoragePerNodeInGbs *int64 `json:"minDbNodeStoragePerNodeInGbs,omitempty"` + MinMemoryPerNodeInGbs *int64 `json:"minMemoryPerNodeInGbs,omitempty"` + MinStorageCount *int64 `json:"minStorageCount,omitempty"` + MinimumCoreCount *int64 `json:"minimumCoreCount,omitempty"` + MinimumNodeCount *int64 `json:"minimumNodeCount,omitempty"` + RuntimeMinimumCoreCount *int64 `json:"runtimeMinimumCoreCount,omitempty"` + ShapeFamily *string `json:"shapeFamily,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/predicates.go b/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/predicates.go new file mode 100644 index 00000000000..34452fe4cf6 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/predicates.go @@ -0,0 +1,27 @@ +package dbsystemshapes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DbSystemShapeOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p DbSystemShapeOperationPredicate) Matches(input DbSystemShape) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/version.go b/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/version.go new file mode 100644 index 00000000000..6fc51a3092b --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dbsystemshapes/version.go @@ -0,0 +1,12 @@ +package dbsystemshapes + +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-06-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/dbsystemshapes/%s", defaultApiVersion) +} diff --git a/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/README.md b/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/README.md new file mode 100644 index 00000000000..36be3379489 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/dnsprivateviews` Documentation + +The `dnsprivateviews` SDK allows for interaction with the Azure Resource Manager Service `oracledatabase` (API Version `2024-06-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/oracledatabase/2024-06-01/dnsprivateviews" +``` + + +### Client Initialization + +```go +client := dnsprivateviews.NewDnsPrivateViewsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DnsPrivateViewsClient.Get` + +```go +ctx := context.TODO() +id := dnsprivateviews.NewDnsPrivateViewID("12345678-1234-9876-4563-123456789012", "locationValue", "dnsPrivateViewValue") + +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: `DnsPrivateViewsClient.ListByLocation` + +```go +ctx := context.TODO() +id := dnsprivateviews.NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + +// alternatively `client.ListByLocation(ctx, id)` can be used to do batched pagination +items, err := client.ListByLocationComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/client.go b/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/client.go new file mode 100644 index 00000000000..3c698794fc2 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/client.go @@ -0,0 +1,26 @@ +package dnsprivateviews + +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 DnsPrivateViewsClient struct { + Client *resourcemanager.Client +} + +func NewDnsPrivateViewsClientWithBaseURI(sdkApi sdkEnv.Api) (*DnsPrivateViewsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "dnsprivateviews", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DnsPrivateViewsClient: %+v", err) + } + + return &DnsPrivateViewsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/constants.go b/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/constants.go new file mode 100644 index 00000000000..2dbb8a48f9e --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/constants.go @@ -0,0 +1,101 @@ +package dnsprivateviews + +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 DnsPrivateViewsLifecycleState string + +const ( + DnsPrivateViewsLifecycleStateActive DnsPrivateViewsLifecycleState = "Active" + DnsPrivateViewsLifecycleStateDeleted DnsPrivateViewsLifecycleState = "Deleted" + DnsPrivateViewsLifecycleStateDeleting DnsPrivateViewsLifecycleState = "Deleting" + DnsPrivateViewsLifecycleStateUpdating DnsPrivateViewsLifecycleState = "Updating" +) + +func PossibleValuesForDnsPrivateViewsLifecycleState() []string { + return []string{ + string(DnsPrivateViewsLifecycleStateActive), + string(DnsPrivateViewsLifecycleStateDeleted), + string(DnsPrivateViewsLifecycleStateDeleting), + string(DnsPrivateViewsLifecycleStateUpdating), + } +} + +func (s *DnsPrivateViewsLifecycleState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDnsPrivateViewsLifecycleState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDnsPrivateViewsLifecycleState(input string) (*DnsPrivateViewsLifecycleState, error) { + vals := map[string]DnsPrivateViewsLifecycleState{ + "active": DnsPrivateViewsLifecycleStateActive, + "deleted": DnsPrivateViewsLifecycleStateDeleted, + "deleting": DnsPrivateViewsLifecycleStateDeleting, + "updating": DnsPrivateViewsLifecycleStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DnsPrivateViewsLifecycleState(input) + return &out, nil +} + +type ResourceProvisioningState string + +const ( + ResourceProvisioningStateCanceled ResourceProvisioningState = "Canceled" + ResourceProvisioningStateFailed ResourceProvisioningState = "Failed" + ResourceProvisioningStateSucceeded ResourceProvisioningState = "Succeeded" +) + +func PossibleValuesForResourceProvisioningState() []string { + return []string{ + string(ResourceProvisioningStateCanceled), + string(ResourceProvisioningStateFailed), + string(ResourceProvisioningStateSucceeded), + } +} + +func (s *ResourceProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResourceProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResourceProvisioningState(input string) (*ResourceProvisioningState, error) { + vals := map[string]ResourceProvisioningState{ + "canceled": ResourceProvisioningStateCanceled, + "failed": ResourceProvisioningStateFailed, + "succeeded": ResourceProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResourceProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/id_dnsprivateview.go b/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/id_dnsprivateview.go new file mode 100644 index 00000000000..83ebdb07fc4 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/id_dnsprivateview.go @@ -0,0 +1,130 @@ +package dnsprivateviews + +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(&DnsPrivateViewId{}) +} + +var _ resourceids.ResourceId = &DnsPrivateViewId{} + +// DnsPrivateViewId is a struct representing the Resource ID for a Dns Private View +type DnsPrivateViewId struct { + SubscriptionId string + LocationName string + DnsPrivateViewName string +} + +// NewDnsPrivateViewID returns a new DnsPrivateViewId struct +func NewDnsPrivateViewID(subscriptionId string, locationName string, dnsPrivateViewName string) DnsPrivateViewId { + return DnsPrivateViewId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + DnsPrivateViewName: dnsPrivateViewName, + } +} + +// ParseDnsPrivateViewID parses 'input' into a DnsPrivateViewId +func ParseDnsPrivateViewID(input string) (*DnsPrivateViewId, error) { + parser := resourceids.NewParserFromResourceIdType(&DnsPrivateViewId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DnsPrivateViewId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDnsPrivateViewIDInsensitively parses 'input' case-insensitively into a DnsPrivateViewId +// note: this method should only be used for API response data and not user input +func ParseDnsPrivateViewIDInsensitively(input string) (*DnsPrivateViewId, error) { + parser := resourceids.NewParserFromResourceIdType(&DnsPrivateViewId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DnsPrivateViewId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DnsPrivateViewId) 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) + } + + if id.DnsPrivateViewName, ok = input.Parsed["dnsPrivateViewName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "dnsPrivateViewName", input) + } + + return nil +} + +// ValidateDnsPrivateViewID checks that 'input' can be parsed as a Dns Private View ID +func ValidateDnsPrivateViewID(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 := ParseDnsPrivateViewID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Dns Private View ID +func (id DnsPrivateViewId) ID() string { + fmtString := "/subscriptions/%s/providers/Oracle.Database/locations/%s/dnsPrivateViews/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName, id.DnsPrivateViewName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Dns Private View ID +func (id DnsPrivateViewId) 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("staticOracleDatabase", "Oracle.Database", "Oracle.Database"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationValue"), + resourceids.StaticSegment("staticDnsPrivateViews", "dnsPrivateViews", "dnsPrivateViews"), + resourceids.UserSpecifiedSegment("dnsPrivateViewName", "dnsPrivateViewValue"), + } +} + +// String returns a human-readable description of this Dns Private View ID +func (id DnsPrivateViewId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + fmt.Sprintf("Dns Private View Name: %q", id.DnsPrivateViewName), + } + return fmt.Sprintf("Dns Private View (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/id_dnsprivateview_test.go b/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/id_dnsprivateview_test.go new file mode 100644 index 00000000000..9157653977b --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/id_dnsprivateview_test.go @@ -0,0 +1,282 @@ +package dnsprivateviews + +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 = &DnsPrivateViewId{} + +func TestNewDnsPrivateViewID(t *testing.T) { + id := NewDnsPrivateViewID("12345678-1234-9876-4563-123456789012", "locationValue", "dnsPrivateViewValue") + + 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") + } + + if id.DnsPrivateViewName != "dnsPrivateViewValue" { + t.Fatalf("Expected %q but got %q for Segment 'DnsPrivateViewName'", id.DnsPrivateViewName, "dnsPrivateViewValue") + } +} + +func TestFormatDnsPrivateViewID(t *testing.T) { + actual := NewDnsPrivateViewID("12345678-1234-9876-4563-123456789012", "locationValue", "dnsPrivateViewValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/dnsPrivateViews/dnsPrivateViewValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDnsPrivateViewID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DnsPrivateViewId + }{ + { + // 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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/dnsPrivateViews", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/dnsPrivateViews/dnsPrivateViewValue", + Expected: &DnsPrivateViewId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + DnsPrivateViewName: "dnsPrivateViewValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/dnsPrivateViews/dnsPrivateViewValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDnsPrivateViewID(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) + } + + if actual.DnsPrivateViewName != v.Expected.DnsPrivateViewName { + t.Fatalf("Expected %q but got %q for DnsPrivateViewName", v.Expected.DnsPrivateViewName, actual.DnsPrivateViewName) + } + + } +} + +func TestParseDnsPrivateViewIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DnsPrivateViewId + }{ + { + // 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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs/lOcAtIoNvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/dnsPrivateViews", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs/lOcAtIoNvAlUe/dNsPrIvAtEvIeWs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/dnsPrivateViews/dnsPrivateViewValue", + Expected: &DnsPrivateViewId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + DnsPrivateViewName: "dnsPrivateViewValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/dnsPrivateViews/dnsPrivateViewValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs/lOcAtIoNvAlUe/dNsPrIvAtEvIeWs/dNsPrIvAtEvIeWvAlUe", + Expected: &DnsPrivateViewId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNvAlUe", + DnsPrivateViewName: "dNsPrIvAtEvIeWvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs/lOcAtIoNvAlUe/dNsPrIvAtEvIeWs/dNsPrIvAtEvIeWvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDnsPrivateViewIDInsensitively(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) + } + + if actual.DnsPrivateViewName != v.Expected.DnsPrivateViewName { + t.Fatalf("Expected %q but got %q for DnsPrivateViewName", v.Expected.DnsPrivateViewName, actual.DnsPrivateViewName) + } + + } +} + +func TestSegmentsForDnsPrivateViewId(t *testing.T) { + segments := DnsPrivateViewId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DnsPrivateViewId 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/oracledatabase/2024-06-01/dnsprivateviews/id_location.go b/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/id_location.go new file mode 100644 index 00000000000..15e9c47d19d --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/id_location.go @@ -0,0 +1,121 @@ +package dnsprivateviews + +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/Oracle.Database/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("staticOracleDatabase", "Oracle.Database", "Oracle.Database"), + 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/oracledatabase/2024-06-01/dnsprivateviews/id_location_test.go b/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/id_location_test.go new file mode 100644 index 00000000000..8f685cf2d3f --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/id_location_test.go @@ -0,0 +1,237 @@ +package dnsprivateviews + +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/Oracle.Database/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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/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/Oracle.Database/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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/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/Oracle.Database/locations/locationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/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/oRaClE.DaTaBaSe/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/oracledatabase/2024-06-01/dnsprivateviews/method_get.go b/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/method_get.go new file mode 100644 index 00000000000..7caa55aa4b8 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/method_get.go @@ -0,0 +1,54 @@ +package dnsprivateviews + +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 *DnsPrivateView +} + +// Get ... +func (c DnsPrivateViewsClient) Get(ctx context.Context, id DnsPrivateViewId) (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 DnsPrivateView + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/method_listbylocation.go b/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/method_listbylocation.go new file mode 100644 index 00000000000..a0a0c822770 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/method_listbylocation.go @@ -0,0 +1,105 @@ +package dnsprivateviews + +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 ListByLocationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DnsPrivateView +} + +type ListByLocationCompleteResult struct { + LatestHttpResponse *http.Response + Items []DnsPrivateView +} + +type ListByLocationCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByLocationCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByLocation ... +func (c DnsPrivateViewsClient) ListByLocation(ctx context.Context, id LocationId) (result ListByLocationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByLocationCustomPager{}, + Path: fmt.Sprintf("%s/dnsPrivateViews", 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 *[]DnsPrivateView `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByLocationComplete retrieves all the results into a single object +func (c DnsPrivateViewsClient) ListByLocationComplete(ctx context.Context, id LocationId) (ListByLocationCompleteResult, error) { + return c.ListByLocationCompleteMatchingPredicate(ctx, id, DnsPrivateViewOperationPredicate{}) +} + +// ListByLocationCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DnsPrivateViewsClient) ListByLocationCompleteMatchingPredicate(ctx context.Context, id LocationId, predicate DnsPrivateViewOperationPredicate) (result ListByLocationCompleteResult, err error) { + items := make([]DnsPrivateView, 0) + + resp, err := c.ListByLocation(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByLocationCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/model_dnsprivateview.go b/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/model_dnsprivateview.go new file mode 100644 index 00000000000..fbf51b79e0f --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/model_dnsprivateview.go @@ -0,0 +1,16 @@ +package dnsprivateviews + +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 DnsPrivateView struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DnsPrivateViewProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/model_dnsprivateviewproperties.go b/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/model_dnsprivateviewproperties.go new file mode 100644 index 00000000000..40cd3cf0a93 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/model_dnsprivateviewproperties.go @@ -0,0 +1,45 @@ +package dnsprivateviews + +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 DnsPrivateViewProperties struct { + DisplayName *string `json:"displayName,omitempty"` + IsProtected *bool `json:"isProtected,omitempty"` + LifecycleState *DnsPrivateViewsLifecycleState `json:"lifecycleState,omitempty"` + Ocid *string `json:"ocid,omitempty"` + ProvisioningState *ResourceProvisioningState `json:"provisioningState,omitempty"` + Self *string `json:"self,omitempty"` + TimeCreated *string `json:"timeCreated,omitempty"` + TimeUpdated *string `json:"timeUpdated,omitempty"` +} + +func (o *DnsPrivateViewProperties) GetTimeCreatedAsTime() (*time.Time, error) { + if o.TimeCreated == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeCreated, "2006-01-02T15:04:05Z07:00") +} + +func (o *DnsPrivateViewProperties) SetTimeCreatedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeCreated = &formatted +} + +func (o *DnsPrivateViewProperties) GetTimeUpdatedAsTime() (*time.Time, error) { + if o.TimeUpdated == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeUpdated, "2006-01-02T15:04:05Z07:00") +} + +func (o *DnsPrivateViewProperties) SetTimeUpdatedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeUpdated = &formatted +} diff --git a/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/predicates.go b/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/predicates.go new file mode 100644 index 00000000000..294303d391a --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/predicates.go @@ -0,0 +1,27 @@ +package dnsprivateviews + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DnsPrivateViewOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p DnsPrivateViewOperationPredicate) Matches(input DnsPrivateView) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/version.go b/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/version.go new file mode 100644 index 00000000000..6f15b75a621 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dnsprivateviews/version.go @@ -0,0 +1,12 @@ +package dnsprivateviews + +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-06-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/dnsprivateviews/%s", defaultApiVersion) +} diff --git a/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/README.md b/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/README.md new file mode 100644 index 00000000000..26f284a66f6 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/dnsprivatezones` Documentation + +The `dnsprivatezones` SDK allows for interaction with the Azure Resource Manager Service `oracledatabase` (API Version `2024-06-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/oracledatabase/2024-06-01/dnsprivatezones" +``` + + +### Client Initialization + +```go +client := dnsprivatezones.NewDnsPrivateZonesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DnsPrivateZonesClient.Get` + +```go +ctx := context.TODO() +id := dnsprivatezones.NewDnsPrivateZoneID("12345678-1234-9876-4563-123456789012", "locationValue", "dnsPrivateZoneValue") + +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: `DnsPrivateZonesClient.ListByLocation` + +```go +ctx := context.TODO() +id := dnsprivatezones.NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + +// alternatively `client.ListByLocation(ctx, id)` can be used to do batched pagination +items, err := client.ListByLocationComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/client.go b/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/client.go new file mode 100644 index 00000000000..00a326391b3 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/client.go @@ -0,0 +1,26 @@ +package dnsprivatezones + +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 DnsPrivateZonesClient struct { + Client *resourcemanager.Client +} + +func NewDnsPrivateZonesClientWithBaseURI(sdkApi sdkEnv.Api) (*DnsPrivateZonesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "dnsprivatezones", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DnsPrivateZonesClient: %+v", err) + } + + return &DnsPrivateZonesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/constants.go b/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/constants.go new file mode 100644 index 00000000000..e9502880546 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/constants.go @@ -0,0 +1,145 @@ +package dnsprivatezones + +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 DnsPrivateZonesLifecycleState string + +const ( + DnsPrivateZonesLifecycleStateActive DnsPrivateZonesLifecycleState = "Active" + DnsPrivateZonesLifecycleStateCreating DnsPrivateZonesLifecycleState = "Creating" + DnsPrivateZonesLifecycleStateDeleted DnsPrivateZonesLifecycleState = "Deleted" + DnsPrivateZonesLifecycleStateDeleting DnsPrivateZonesLifecycleState = "Deleting" + DnsPrivateZonesLifecycleStateUpdating DnsPrivateZonesLifecycleState = "Updating" +) + +func PossibleValuesForDnsPrivateZonesLifecycleState() []string { + return []string{ + string(DnsPrivateZonesLifecycleStateActive), + string(DnsPrivateZonesLifecycleStateCreating), + string(DnsPrivateZonesLifecycleStateDeleted), + string(DnsPrivateZonesLifecycleStateDeleting), + string(DnsPrivateZonesLifecycleStateUpdating), + } +} + +func (s *DnsPrivateZonesLifecycleState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDnsPrivateZonesLifecycleState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDnsPrivateZonesLifecycleState(input string) (*DnsPrivateZonesLifecycleState, error) { + vals := map[string]DnsPrivateZonesLifecycleState{ + "active": DnsPrivateZonesLifecycleStateActive, + "creating": DnsPrivateZonesLifecycleStateCreating, + "deleted": DnsPrivateZonesLifecycleStateDeleted, + "deleting": DnsPrivateZonesLifecycleStateDeleting, + "updating": DnsPrivateZonesLifecycleStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DnsPrivateZonesLifecycleState(input) + return &out, nil +} + +type ResourceProvisioningState string + +const ( + ResourceProvisioningStateCanceled ResourceProvisioningState = "Canceled" + ResourceProvisioningStateFailed ResourceProvisioningState = "Failed" + ResourceProvisioningStateSucceeded ResourceProvisioningState = "Succeeded" +) + +func PossibleValuesForResourceProvisioningState() []string { + return []string{ + string(ResourceProvisioningStateCanceled), + string(ResourceProvisioningStateFailed), + string(ResourceProvisioningStateSucceeded), + } +} + +func (s *ResourceProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResourceProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResourceProvisioningState(input string) (*ResourceProvisioningState, error) { + vals := map[string]ResourceProvisioningState{ + "canceled": ResourceProvisioningStateCanceled, + "failed": ResourceProvisioningStateFailed, + "succeeded": ResourceProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResourceProvisioningState(input) + return &out, nil +} + +type ZoneType string + +const ( + ZoneTypePrimary ZoneType = "Primary" + ZoneTypeSecondary ZoneType = "Secondary" +) + +func PossibleValuesForZoneType() []string { + return []string{ + string(ZoneTypePrimary), + string(ZoneTypeSecondary), + } +} + +func (s *ZoneType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseZoneType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseZoneType(input string) (*ZoneType, error) { + vals := map[string]ZoneType{ + "primary": ZoneTypePrimary, + "secondary": ZoneTypeSecondary, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ZoneType(input) + return &out, nil +} diff --git a/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/id_dnsprivatezone.go b/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/id_dnsprivatezone.go new file mode 100644 index 00000000000..bc16d28dc4f --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/id_dnsprivatezone.go @@ -0,0 +1,130 @@ +package dnsprivatezones + +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(&DnsPrivateZoneId{}) +} + +var _ resourceids.ResourceId = &DnsPrivateZoneId{} + +// DnsPrivateZoneId is a struct representing the Resource ID for a Dns Private Zone +type DnsPrivateZoneId struct { + SubscriptionId string + LocationName string + DnsPrivateZoneName string +} + +// NewDnsPrivateZoneID returns a new DnsPrivateZoneId struct +func NewDnsPrivateZoneID(subscriptionId string, locationName string, dnsPrivateZoneName string) DnsPrivateZoneId { + return DnsPrivateZoneId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + DnsPrivateZoneName: dnsPrivateZoneName, + } +} + +// ParseDnsPrivateZoneID parses 'input' into a DnsPrivateZoneId +func ParseDnsPrivateZoneID(input string) (*DnsPrivateZoneId, error) { + parser := resourceids.NewParserFromResourceIdType(&DnsPrivateZoneId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DnsPrivateZoneId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDnsPrivateZoneIDInsensitively parses 'input' case-insensitively into a DnsPrivateZoneId +// note: this method should only be used for API response data and not user input +func ParseDnsPrivateZoneIDInsensitively(input string) (*DnsPrivateZoneId, error) { + parser := resourceids.NewParserFromResourceIdType(&DnsPrivateZoneId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DnsPrivateZoneId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DnsPrivateZoneId) 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) + } + + if id.DnsPrivateZoneName, ok = input.Parsed["dnsPrivateZoneName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "dnsPrivateZoneName", input) + } + + return nil +} + +// ValidateDnsPrivateZoneID checks that 'input' can be parsed as a Dns Private Zone ID +func ValidateDnsPrivateZoneID(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 := ParseDnsPrivateZoneID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Dns Private Zone ID +func (id DnsPrivateZoneId) ID() string { + fmtString := "/subscriptions/%s/providers/Oracle.Database/locations/%s/dnsPrivateZones/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName, id.DnsPrivateZoneName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Dns Private Zone ID +func (id DnsPrivateZoneId) 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("staticOracleDatabase", "Oracle.Database", "Oracle.Database"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationValue"), + resourceids.StaticSegment("staticDnsPrivateZones", "dnsPrivateZones", "dnsPrivateZones"), + resourceids.UserSpecifiedSegment("dnsPrivateZoneName", "dnsPrivateZoneValue"), + } +} + +// String returns a human-readable description of this Dns Private Zone ID +func (id DnsPrivateZoneId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + fmt.Sprintf("Dns Private Zone Name: %q", id.DnsPrivateZoneName), + } + return fmt.Sprintf("Dns Private Zone (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/id_dnsprivatezone_test.go b/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/id_dnsprivatezone_test.go new file mode 100644 index 00000000000..5eb144eac06 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/id_dnsprivatezone_test.go @@ -0,0 +1,282 @@ +package dnsprivatezones + +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 = &DnsPrivateZoneId{} + +func TestNewDnsPrivateZoneID(t *testing.T) { + id := NewDnsPrivateZoneID("12345678-1234-9876-4563-123456789012", "locationValue", "dnsPrivateZoneValue") + + 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") + } + + if id.DnsPrivateZoneName != "dnsPrivateZoneValue" { + t.Fatalf("Expected %q but got %q for Segment 'DnsPrivateZoneName'", id.DnsPrivateZoneName, "dnsPrivateZoneValue") + } +} + +func TestFormatDnsPrivateZoneID(t *testing.T) { + actual := NewDnsPrivateZoneID("12345678-1234-9876-4563-123456789012", "locationValue", "dnsPrivateZoneValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/dnsPrivateZones/dnsPrivateZoneValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDnsPrivateZoneID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DnsPrivateZoneId + }{ + { + // 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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/dnsPrivateZones", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/dnsPrivateZones/dnsPrivateZoneValue", + Expected: &DnsPrivateZoneId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + DnsPrivateZoneName: "dnsPrivateZoneValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/dnsPrivateZones/dnsPrivateZoneValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDnsPrivateZoneID(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) + } + + if actual.DnsPrivateZoneName != v.Expected.DnsPrivateZoneName { + t.Fatalf("Expected %q but got %q for DnsPrivateZoneName", v.Expected.DnsPrivateZoneName, actual.DnsPrivateZoneName) + } + + } +} + +func TestParseDnsPrivateZoneIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DnsPrivateZoneId + }{ + { + // 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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs/lOcAtIoNvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/dnsPrivateZones", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs/lOcAtIoNvAlUe/dNsPrIvAtEzOnEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/dnsPrivateZones/dnsPrivateZoneValue", + Expected: &DnsPrivateZoneId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + DnsPrivateZoneName: "dnsPrivateZoneValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/dnsPrivateZones/dnsPrivateZoneValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs/lOcAtIoNvAlUe/dNsPrIvAtEzOnEs/dNsPrIvAtEzOnEvAlUe", + Expected: &DnsPrivateZoneId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNvAlUe", + DnsPrivateZoneName: "dNsPrIvAtEzOnEvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs/lOcAtIoNvAlUe/dNsPrIvAtEzOnEs/dNsPrIvAtEzOnEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDnsPrivateZoneIDInsensitively(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) + } + + if actual.DnsPrivateZoneName != v.Expected.DnsPrivateZoneName { + t.Fatalf("Expected %q but got %q for DnsPrivateZoneName", v.Expected.DnsPrivateZoneName, actual.DnsPrivateZoneName) + } + + } +} + +func TestSegmentsForDnsPrivateZoneId(t *testing.T) { + segments := DnsPrivateZoneId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DnsPrivateZoneId 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/oracledatabase/2024-06-01/dnsprivatezones/id_location.go b/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/id_location.go new file mode 100644 index 00000000000..75b18688608 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/id_location.go @@ -0,0 +1,121 @@ +package dnsprivatezones + +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/Oracle.Database/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("staticOracleDatabase", "Oracle.Database", "Oracle.Database"), + 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/oracledatabase/2024-06-01/dnsprivatezones/id_location_test.go b/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/id_location_test.go new file mode 100644 index 00000000000..d299ebad0c4 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/id_location_test.go @@ -0,0 +1,237 @@ +package dnsprivatezones + +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/Oracle.Database/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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/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/Oracle.Database/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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/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/Oracle.Database/locations/locationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/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/oRaClE.DaTaBaSe/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/oracledatabase/2024-06-01/dnsprivatezones/method_get.go b/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/method_get.go new file mode 100644 index 00000000000..5dee2634a3d --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/method_get.go @@ -0,0 +1,54 @@ +package dnsprivatezones + +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 *DnsPrivateZone +} + +// Get ... +func (c DnsPrivateZonesClient) Get(ctx context.Context, id DnsPrivateZoneId) (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 DnsPrivateZone + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/method_listbylocation.go b/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/method_listbylocation.go new file mode 100644 index 00000000000..a8f06fd1edc --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/method_listbylocation.go @@ -0,0 +1,105 @@ +package dnsprivatezones + +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 ListByLocationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DnsPrivateZone +} + +type ListByLocationCompleteResult struct { + LatestHttpResponse *http.Response + Items []DnsPrivateZone +} + +type ListByLocationCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByLocationCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByLocation ... +func (c DnsPrivateZonesClient) ListByLocation(ctx context.Context, id LocationId) (result ListByLocationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByLocationCustomPager{}, + Path: fmt.Sprintf("%s/dnsPrivateZones", 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 *[]DnsPrivateZone `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByLocationComplete retrieves all the results into a single object +func (c DnsPrivateZonesClient) ListByLocationComplete(ctx context.Context, id LocationId) (ListByLocationCompleteResult, error) { + return c.ListByLocationCompleteMatchingPredicate(ctx, id, DnsPrivateZoneOperationPredicate{}) +} + +// ListByLocationCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DnsPrivateZonesClient) ListByLocationCompleteMatchingPredicate(ctx context.Context, id LocationId, predicate DnsPrivateZoneOperationPredicate) (result ListByLocationCompleteResult, err error) { + items := make([]DnsPrivateZone, 0) + + resp, err := c.ListByLocation(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByLocationCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/model_dnsprivatezone.go b/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/model_dnsprivatezone.go new file mode 100644 index 00000000000..753c8a9c469 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/model_dnsprivatezone.go @@ -0,0 +1,16 @@ +package dnsprivatezones + +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 DnsPrivateZone struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DnsPrivateZoneProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/model_dnsprivatezoneproperties.go b/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/model_dnsprivatezoneproperties.go new file mode 100644 index 00000000000..680bff102fe --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/model_dnsprivatezoneproperties.go @@ -0,0 +1,35 @@ +package dnsprivatezones + +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 DnsPrivateZoneProperties struct { + IsProtected *bool `json:"isProtected,omitempty"` + LifecycleState *DnsPrivateZonesLifecycleState `json:"lifecycleState,omitempty"` + Ocid *string `json:"ocid,omitempty"` + ProvisioningState *ResourceProvisioningState `json:"provisioningState,omitempty"` + Self *string `json:"self,omitempty"` + Serial *int64 `json:"serial,omitempty"` + TimeCreated *string `json:"timeCreated,omitempty"` + Version *string `json:"version,omitempty"` + ViewId *string `json:"viewId,omitempty"` + ZoneType *ZoneType `json:"zoneType,omitempty"` +} + +func (o *DnsPrivateZoneProperties) GetTimeCreatedAsTime() (*time.Time, error) { + if o.TimeCreated == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeCreated, "2006-01-02T15:04:05Z07:00") +} + +func (o *DnsPrivateZoneProperties) SetTimeCreatedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeCreated = &formatted +} diff --git a/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/predicates.go b/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/predicates.go new file mode 100644 index 00000000000..c135bf5afb1 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/predicates.go @@ -0,0 +1,27 @@ +package dnsprivatezones + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DnsPrivateZoneOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p DnsPrivateZoneOperationPredicate) Matches(input DnsPrivateZone) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/version.go b/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/version.go new file mode 100644 index 00000000000..c297b3ada65 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/dnsprivatezones/version.go @@ -0,0 +1,12 @@ +package dnsprivatezones + +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-06-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/dnsprivatezones/%s", defaultApiVersion) +} diff --git a/resource-manager/oracledatabase/2024-06-01/giversions/README.md b/resource-manager/oracledatabase/2024-06-01/giversions/README.md new file mode 100644 index 00000000000..aa7d3982745 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/giversions/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/giversions` Documentation + +The `giversions` SDK allows for interaction with the Azure Resource Manager Service `oracledatabase` (API Version `2024-06-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/oracledatabase/2024-06-01/giversions" +``` + + +### Client Initialization + +```go +client := giversions.NewGiVersionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `GiVersionsClient.Get` + +```go +ctx := context.TODO() +id := giversions.NewGiVersionID("12345678-1234-9876-4563-123456789012", "locationValue", "giVersionValue") + +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: `GiVersionsClient.ListByLocation` + +```go +ctx := context.TODO() +id := giversions.NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + +// alternatively `client.ListByLocation(ctx, id)` can be used to do batched pagination +items, err := client.ListByLocationComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/oracledatabase/2024-06-01/giversions/client.go b/resource-manager/oracledatabase/2024-06-01/giversions/client.go new file mode 100644 index 00000000000..00d69beb1d9 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/giversions/client.go @@ -0,0 +1,26 @@ +package giversions + +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 GiVersionsClient struct { + Client *resourcemanager.Client +} + +func NewGiVersionsClientWithBaseURI(sdkApi sdkEnv.Api) (*GiVersionsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "giversions", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating GiVersionsClient: %+v", err) + } + + return &GiVersionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/oracledatabase/2024-06-01/giversions/id_giversion.go b/resource-manager/oracledatabase/2024-06-01/giversions/id_giversion.go new file mode 100644 index 00000000000..50eccbc7815 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/giversions/id_giversion.go @@ -0,0 +1,130 @@ +package giversions + +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(&GiVersionId{}) +} + +var _ resourceids.ResourceId = &GiVersionId{} + +// GiVersionId is a struct representing the Resource ID for a Gi Version +type GiVersionId struct { + SubscriptionId string + LocationName string + GiVersionName string +} + +// NewGiVersionID returns a new GiVersionId struct +func NewGiVersionID(subscriptionId string, locationName string, giVersionName string) GiVersionId { + return GiVersionId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + GiVersionName: giVersionName, + } +} + +// ParseGiVersionID parses 'input' into a GiVersionId +func ParseGiVersionID(input string) (*GiVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&GiVersionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := GiVersionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseGiVersionIDInsensitively parses 'input' case-insensitively into a GiVersionId +// note: this method should only be used for API response data and not user input +func ParseGiVersionIDInsensitively(input string) (*GiVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&GiVersionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := GiVersionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *GiVersionId) 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) + } + + if id.GiVersionName, ok = input.Parsed["giVersionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "giVersionName", input) + } + + return nil +} + +// ValidateGiVersionID checks that 'input' can be parsed as a Gi Version ID +func ValidateGiVersionID(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 := ParseGiVersionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Gi Version ID +func (id GiVersionId) ID() string { + fmtString := "/subscriptions/%s/providers/Oracle.Database/locations/%s/giVersions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName, id.GiVersionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Gi Version ID +func (id GiVersionId) 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("staticOracleDatabase", "Oracle.Database", "Oracle.Database"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationValue"), + resourceids.StaticSegment("staticGiVersions", "giVersions", "giVersions"), + resourceids.UserSpecifiedSegment("giVersionName", "giVersionValue"), + } +} + +// String returns a human-readable description of this Gi Version ID +func (id GiVersionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + fmt.Sprintf("Gi Version Name: %q", id.GiVersionName), + } + return fmt.Sprintf("Gi Version (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/oracledatabase/2024-06-01/giversions/id_giversion_test.go b/resource-manager/oracledatabase/2024-06-01/giversions/id_giversion_test.go new file mode 100644 index 00000000000..cb7f35e1e2d --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/giversions/id_giversion_test.go @@ -0,0 +1,282 @@ +package giversions + +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 = &GiVersionId{} + +func TestNewGiVersionID(t *testing.T) { + id := NewGiVersionID("12345678-1234-9876-4563-123456789012", "locationValue", "giVersionValue") + + 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") + } + + if id.GiVersionName != "giVersionValue" { + t.Fatalf("Expected %q but got %q for Segment 'GiVersionName'", id.GiVersionName, "giVersionValue") + } +} + +func TestFormatGiVersionID(t *testing.T) { + actual := NewGiVersionID("12345678-1234-9876-4563-123456789012", "locationValue", "giVersionValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/giVersions/giVersionValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseGiVersionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *GiVersionId + }{ + { + // 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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/giVersions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/giVersions/giVersionValue", + Expected: &GiVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + GiVersionName: "giVersionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/giVersions/giVersionValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseGiVersionID(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) + } + + if actual.GiVersionName != v.Expected.GiVersionName { + t.Fatalf("Expected %q but got %q for GiVersionName", v.Expected.GiVersionName, actual.GiVersionName) + } + + } +} + +func TestParseGiVersionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *GiVersionId + }{ + { + // 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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs/lOcAtIoNvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/giVersions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs/lOcAtIoNvAlUe/gIvErSiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/giVersions/giVersionValue", + Expected: &GiVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + GiVersionName: "giVersionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/giVersions/giVersionValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs/lOcAtIoNvAlUe/gIvErSiOnS/gIvErSiOnVaLuE", + Expected: &GiVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNvAlUe", + GiVersionName: "gIvErSiOnVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs/lOcAtIoNvAlUe/gIvErSiOnS/gIvErSiOnVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseGiVersionIDInsensitively(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) + } + + if actual.GiVersionName != v.Expected.GiVersionName { + t.Fatalf("Expected %q but got %q for GiVersionName", v.Expected.GiVersionName, actual.GiVersionName) + } + + } +} + +func TestSegmentsForGiVersionId(t *testing.T) { + segments := GiVersionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("GiVersionId 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/oracledatabase/2024-06-01/giversions/id_location.go b/resource-manager/oracledatabase/2024-06-01/giversions/id_location.go new file mode 100644 index 00000000000..610b7ef1906 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/giversions/id_location.go @@ -0,0 +1,121 @@ +package giversions + +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/Oracle.Database/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("staticOracleDatabase", "Oracle.Database", "Oracle.Database"), + 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/oracledatabase/2024-06-01/giversions/id_location_test.go b/resource-manager/oracledatabase/2024-06-01/giversions/id_location_test.go new file mode 100644 index 00000000000..3a9d53d15a3 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/giversions/id_location_test.go @@ -0,0 +1,237 @@ +package giversions + +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/Oracle.Database/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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/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/Oracle.Database/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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/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/Oracle.Database/locations/locationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/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/oRaClE.DaTaBaSe/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/oracledatabase/2024-06-01/giversions/method_get.go b/resource-manager/oracledatabase/2024-06-01/giversions/method_get.go new file mode 100644 index 00000000000..1a89493ad3d --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/giversions/method_get.go @@ -0,0 +1,54 @@ +package giversions + +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 *GiVersion +} + +// Get ... +func (c GiVersionsClient) Get(ctx context.Context, id GiVersionId) (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 GiVersion + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/oracledatabase/2024-06-01/giversions/method_listbylocation.go b/resource-manager/oracledatabase/2024-06-01/giversions/method_listbylocation.go new file mode 100644 index 00000000000..b07237060ba --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/giversions/method_listbylocation.go @@ -0,0 +1,105 @@ +package giversions + +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 ListByLocationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]GiVersion +} + +type ListByLocationCompleteResult struct { + LatestHttpResponse *http.Response + Items []GiVersion +} + +type ListByLocationCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByLocationCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByLocation ... +func (c GiVersionsClient) ListByLocation(ctx context.Context, id LocationId) (result ListByLocationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByLocationCustomPager{}, + Path: fmt.Sprintf("%s/giVersions", 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 *[]GiVersion `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByLocationComplete retrieves all the results into a single object +func (c GiVersionsClient) ListByLocationComplete(ctx context.Context, id LocationId) (ListByLocationCompleteResult, error) { + return c.ListByLocationCompleteMatchingPredicate(ctx, id, GiVersionOperationPredicate{}) +} + +// ListByLocationCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c GiVersionsClient) ListByLocationCompleteMatchingPredicate(ctx context.Context, id LocationId, predicate GiVersionOperationPredicate) (result ListByLocationCompleteResult, err error) { + items := make([]GiVersion, 0) + + resp, err := c.ListByLocation(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByLocationCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/oracledatabase/2024-06-01/giversions/model_giversion.go b/resource-manager/oracledatabase/2024-06-01/giversions/model_giversion.go new file mode 100644 index 00000000000..a088d6eabc4 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/giversions/model_giversion.go @@ -0,0 +1,16 @@ +package giversions + +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 GiVersion struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *GiVersionProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/giversions/model_giversionproperties.go b/resource-manager/oracledatabase/2024-06-01/giversions/model_giversionproperties.go new file mode 100644 index 00000000000..ca86e602826 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/giversions/model_giversionproperties.go @@ -0,0 +1,8 @@ +package giversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GiVersionProperties struct { + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/giversions/predicates.go b/resource-manager/oracledatabase/2024-06-01/giversions/predicates.go new file mode 100644 index 00000000000..1ffcef5ca0e --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/giversions/predicates.go @@ -0,0 +1,27 @@ +package giversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GiVersionOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p GiVersionOperationPredicate) Matches(input GiVersion) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/oracledatabase/2024-06-01/giversions/version.go b/resource-manager/oracledatabase/2024-06-01/giversions/version.go new file mode 100644 index 00000000000..36d335193b2 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/giversions/version.go @@ -0,0 +1,12 @@ +package giversions + +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-06-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/giversions/%s", defaultApiVersion) +} diff --git a/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/README.md b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/README.md new file mode 100644 index 00000000000..09bef5af8ae --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/README.md @@ -0,0 +1,153 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions` Documentation + +The `oraclesubscriptions` SDK allows for interaction with the Azure Resource Manager Service `oracledatabase` (API Version `2024-06-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/oracledatabase/2024-06-01/oraclesubscriptions" +``` + + +### Client Initialization + +```go +client := oraclesubscriptions.NewOracleSubscriptionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `OracleSubscriptionsClient.AddAzureSubscriptions` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +payload := oraclesubscriptions.AzureSubscriptions{ + // ... +} + + +if err := client.AddAzureSubscriptionsThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `OracleSubscriptionsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +payload := oraclesubscriptions.OracleSubscription{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `OracleSubscriptionsClient.Delete` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `OracleSubscriptionsClient.Get` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +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: `OracleSubscriptionsClient.ListActivationLinks` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +if err := client.ListActivationLinksThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `OracleSubscriptionsClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `OracleSubscriptionsClient.ListCloudAccountDetails` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +if err := client.ListCloudAccountDetailsThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `OracleSubscriptionsClient.ListSaasSubscriptionDetails` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +if err := client.ListSaasSubscriptionDetailsThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `OracleSubscriptionsClient.Update` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +payload := oraclesubscriptions.OracleSubscriptionUpdate{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/client.go b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/client.go new file mode 100644 index 00000000000..0e7729cfc7b --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/client.go @@ -0,0 +1,26 @@ +package oraclesubscriptions + +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 OracleSubscriptionsClient struct { + Client *resourcemanager.Client +} + +func NewOracleSubscriptionsClientWithBaseURI(sdkApi sdkEnv.Api) (*OracleSubscriptionsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "oraclesubscriptions", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating OracleSubscriptionsClient: %+v", err) + } + + return &OracleSubscriptionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/constants.go b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/constants.go new file mode 100644 index 00000000000..c13ecd3a48e --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/constants.go @@ -0,0 +1,183 @@ +package oraclesubscriptions + +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 AddSubscriptionOperationState string + +const ( + AddSubscriptionOperationStateFailed AddSubscriptionOperationState = "Failed" + AddSubscriptionOperationStateSucceeded AddSubscriptionOperationState = "Succeeded" + AddSubscriptionOperationStateUpdating AddSubscriptionOperationState = "Updating" +) + +func PossibleValuesForAddSubscriptionOperationState() []string { + return []string{ + string(AddSubscriptionOperationStateFailed), + string(AddSubscriptionOperationStateSucceeded), + string(AddSubscriptionOperationStateUpdating), + } +} + +func (s *AddSubscriptionOperationState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAddSubscriptionOperationState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAddSubscriptionOperationState(input string) (*AddSubscriptionOperationState, error) { + vals := map[string]AddSubscriptionOperationState{ + "failed": AddSubscriptionOperationStateFailed, + "succeeded": AddSubscriptionOperationStateSucceeded, + "updating": AddSubscriptionOperationStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AddSubscriptionOperationState(input) + return &out, nil +} + +type CloudAccountProvisioningState string + +const ( + CloudAccountProvisioningStateAvailable CloudAccountProvisioningState = "Available" + CloudAccountProvisioningStatePending CloudAccountProvisioningState = "Pending" + CloudAccountProvisioningStateProvisioning CloudAccountProvisioningState = "Provisioning" +) + +func PossibleValuesForCloudAccountProvisioningState() []string { + return []string{ + string(CloudAccountProvisioningStateAvailable), + string(CloudAccountProvisioningStatePending), + string(CloudAccountProvisioningStateProvisioning), + } +} + +func (s *CloudAccountProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCloudAccountProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCloudAccountProvisioningState(input string) (*CloudAccountProvisioningState, error) { + vals := map[string]CloudAccountProvisioningState{ + "available": CloudAccountProvisioningStateAvailable, + "pending": CloudAccountProvisioningStatePending, + "provisioning": CloudAccountProvisioningStateProvisioning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CloudAccountProvisioningState(input) + return &out, nil +} + +type Intent string + +const ( + IntentReset Intent = "Reset" + IntentRetain Intent = "Retain" +) + +func PossibleValuesForIntent() []string { + return []string{ + string(IntentReset), + string(IntentRetain), + } +} + +func (s *Intent) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIntent(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIntent(input string) (*Intent, error) { + vals := map[string]Intent{ + "reset": IntentReset, + "retain": IntentRetain, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Intent(input) + return &out, nil +} + +type OracleSubscriptionProvisioningState string + +const ( + OracleSubscriptionProvisioningStateCanceled OracleSubscriptionProvisioningState = "Canceled" + OracleSubscriptionProvisioningStateFailed OracleSubscriptionProvisioningState = "Failed" + OracleSubscriptionProvisioningStateSucceeded OracleSubscriptionProvisioningState = "Succeeded" +) + +func PossibleValuesForOracleSubscriptionProvisioningState() []string { + return []string{ + string(OracleSubscriptionProvisioningStateCanceled), + string(OracleSubscriptionProvisioningStateFailed), + string(OracleSubscriptionProvisioningStateSucceeded), + } +} + +func (s *OracleSubscriptionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOracleSubscriptionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOracleSubscriptionProvisioningState(input string) (*OracleSubscriptionProvisioningState, error) { + vals := map[string]OracleSubscriptionProvisioningState{ + "canceled": OracleSubscriptionProvisioningStateCanceled, + "failed": OracleSubscriptionProvisioningStateFailed, + "succeeded": OracleSubscriptionProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OracleSubscriptionProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/method_addazuresubscriptions.go b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/method_addazuresubscriptions.go new file mode 100644 index 00000000000..8b020812679 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/method_addazuresubscriptions.go @@ -0,0 +1,74 @@ +package oraclesubscriptions + +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/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 AddAzureSubscriptionsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// AddAzureSubscriptions ... +func (c OracleSubscriptionsClient) AddAzureSubscriptions(ctx context.Context, id commonids.SubscriptionId, input AzureSubscriptions) (result AddAzureSubscriptionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Oracle.Database/oracleSubscriptions/default/addAzureSubscriptions", 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 +} + +// AddAzureSubscriptionsThenPoll performs AddAzureSubscriptions then polls until it's completed +func (c OracleSubscriptionsClient) AddAzureSubscriptionsThenPoll(ctx context.Context, id commonids.SubscriptionId, input AzureSubscriptions) error { + result, err := c.AddAzureSubscriptions(ctx, id, input) + if err != nil { + return fmt.Errorf("performing AddAzureSubscriptions: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after AddAzureSubscriptions: %+v", err) + } + + return nil +} diff --git a/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/method_createorupdate.go b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/method_createorupdate.go new file mode 100644 index 00000000000..e40bd87996d --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/method_createorupdate.go @@ -0,0 +1,76 @@ +package oraclesubscriptions + +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/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 *OracleSubscription +} + +// CreateOrUpdate ... +func (c OracleSubscriptionsClient) CreateOrUpdate(ctx context.Context, id commonids.SubscriptionId, input OracleSubscription) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/providers/Oracle.Database/oracleSubscriptions/default", 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 OracleSubscriptionsClient) CreateOrUpdateThenPoll(ctx context.Context, id commonids.SubscriptionId, input OracleSubscription) 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/oracledatabase/2024-06-01/oraclesubscriptions/method_delete.go b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/method_delete.go new file mode 100644 index 00000000000..3db5d26b956 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/method_delete.go @@ -0,0 +1,71 @@ +package oraclesubscriptions + +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/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 OracleSubscriptionsClient) Delete(ctx context.Context, id commonids.SubscriptionId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/providers/Oracle.Database/oracleSubscriptions/default", 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 OracleSubscriptionsClient) DeleteThenPoll(ctx context.Context, id commonids.SubscriptionId) 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/oracledatabase/2024-06-01/oraclesubscriptions/method_get.go b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/method_get.go new file mode 100644 index 00000000000..56033046138 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/method_get.go @@ -0,0 +1,56 @@ +package oraclesubscriptions + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *OracleSubscription +} + +// Get ... +func (c OracleSubscriptionsClient) Get(ctx context.Context, id commonids.SubscriptionId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Oracle.Database/oracleSubscriptions/default", 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 OracleSubscription + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/method_listactivationlinks.go b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/method_listactivationlinks.go new file mode 100644 index 00000000000..2b8c6c5f589 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/method_listactivationlinks.go @@ -0,0 +1,72 @@ +package oraclesubscriptions + +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/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 ListActivationLinksOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ActivationLinks +} + +// ListActivationLinks ... +func (c OracleSubscriptionsClient) ListActivationLinks(ctx context.Context, id commonids.SubscriptionId) (result ListActivationLinksOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Oracle.Database/oracleSubscriptions/default/listActivationLinks", 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 +} + +// ListActivationLinksThenPoll performs ListActivationLinks then polls until it's completed +func (c OracleSubscriptionsClient) ListActivationLinksThenPoll(ctx context.Context, id commonids.SubscriptionId) error { + result, err := c.ListActivationLinks(ctx, id) + if err != nil { + return fmt.Errorf("performing ListActivationLinks: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ListActivationLinks: %+v", err) + } + + return nil +} diff --git a/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/method_listbysubscription.go b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/method_listbysubscription.go new file mode 100644 index 00000000000..0f79ddbf1f1 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/method_listbysubscription.go @@ -0,0 +1,106 @@ +package oraclesubscriptions + +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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]OracleSubscription +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []OracleSubscription +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c OracleSubscriptionsClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Oracle.Database/oracleSubscriptions", 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 *[]OracleSubscription `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c OracleSubscriptionsClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, OracleSubscriptionOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c OracleSubscriptionsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate OracleSubscriptionOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]OracleSubscription, 0) + + resp, err := c.ListBySubscription(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/method_listcloudaccountdetails.go b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/method_listcloudaccountdetails.go new file mode 100644 index 00000000000..82e0fe4398f --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/method_listcloudaccountdetails.go @@ -0,0 +1,72 @@ +package oraclesubscriptions + +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/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 ListCloudAccountDetailsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *CloudAccountDetails +} + +// ListCloudAccountDetails ... +func (c OracleSubscriptionsClient) ListCloudAccountDetails(ctx context.Context, id commonids.SubscriptionId) (result ListCloudAccountDetailsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Oracle.Database/oracleSubscriptions/default/listCloudAccountDetails", 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 +} + +// ListCloudAccountDetailsThenPoll performs ListCloudAccountDetails then polls until it's completed +func (c OracleSubscriptionsClient) ListCloudAccountDetailsThenPoll(ctx context.Context, id commonids.SubscriptionId) error { + result, err := c.ListCloudAccountDetails(ctx, id) + if err != nil { + return fmt.Errorf("performing ListCloudAccountDetails: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ListCloudAccountDetails: %+v", err) + } + + return nil +} diff --git a/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/method_listsaassubscriptiondetails.go b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/method_listsaassubscriptiondetails.go new file mode 100644 index 00000000000..38a211cf773 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/method_listsaassubscriptiondetails.go @@ -0,0 +1,72 @@ +package oraclesubscriptions + +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/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 ListSaasSubscriptionDetailsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SaasSubscriptionDetails +} + +// ListSaasSubscriptionDetails ... +func (c OracleSubscriptionsClient) ListSaasSubscriptionDetails(ctx context.Context, id commonids.SubscriptionId) (result ListSaasSubscriptionDetailsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Oracle.Database/oracleSubscriptions/default/listSaasSubscriptionDetails", 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 +} + +// ListSaasSubscriptionDetailsThenPoll performs ListSaasSubscriptionDetails then polls until it's completed +func (c OracleSubscriptionsClient) ListSaasSubscriptionDetailsThenPoll(ctx context.Context, id commonids.SubscriptionId) error { + result, err := c.ListSaasSubscriptionDetails(ctx, id) + if err != nil { + return fmt.Errorf("performing ListSaasSubscriptionDetails: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ListSaasSubscriptionDetails: %+v", err) + } + + return nil +} diff --git a/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/method_update.go b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/method_update.go new file mode 100644 index 00000000000..d21b8bc8dd5 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/method_update.go @@ -0,0 +1,76 @@ +package oraclesubscriptions + +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/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 *OracleSubscription +} + +// Update ... +func (c OracleSubscriptionsClient) Update(ctx context.Context, id commonids.SubscriptionId, input OracleSubscriptionUpdate) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/providers/Oracle.Database/oracleSubscriptions/default", 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 OracleSubscriptionsClient) UpdateThenPoll(ctx context.Context, id commonids.SubscriptionId, input OracleSubscriptionUpdate) 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/oracledatabase/2024-06-01/oraclesubscriptions/model_activationlinks.go b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/model_activationlinks.go new file mode 100644 index 00000000000..45a6005a46b --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/model_activationlinks.go @@ -0,0 +1,9 @@ +package oraclesubscriptions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ActivationLinks struct { + ExistingCloudAccountActivationLink *string `json:"existingCloudAccountActivationLink,omitempty"` + NewCloudAccountActivationLink *string `json:"newCloudAccountActivationLink,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/model_azuresubscriptions.go b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/model_azuresubscriptions.go new file mode 100644 index 00000000000..d847d9891cb --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/model_azuresubscriptions.go @@ -0,0 +1,8 @@ +package oraclesubscriptions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureSubscriptions struct { + AzureSubscriptionIds []string `json:"azureSubscriptionIds"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/model_cloudaccountdetails.go b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/model_cloudaccountdetails.go new file mode 100644 index 00000000000..684d25dd96a --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/model_cloudaccountdetails.go @@ -0,0 +1,9 @@ +package oraclesubscriptions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudAccountDetails struct { + CloudAccountHomeRegion *string `json:"cloudAccountHomeRegion,omitempty"` + CloudAccountName *string `json:"cloudAccountName,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/model_oraclesubscription.go b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/model_oraclesubscription.go new file mode 100644 index 00000000000..f7128fc11f5 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/model_oraclesubscription.go @@ -0,0 +1,17 @@ +package oraclesubscriptions + +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 OracleSubscription struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Plan *Plan `json:"plan,omitempty"` + Properties *OracleSubscriptionProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/model_oraclesubscriptionproperties.go b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/model_oraclesubscriptionproperties.go new file mode 100644 index 00000000000..90b625b317c --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/model_oraclesubscriptionproperties.go @@ -0,0 +1,17 @@ +package oraclesubscriptions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OracleSubscriptionProperties struct { + AddSubscriptionOperationState *AddSubscriptionOperationState `json:"addSubscriptionOperationState,omitempty"` + AzureSubscriptionIds *[]string `json:"azureSubscriptionIds,omitempty"` + CloudAccountId *string `json:"cloudAccountId,omitempty"` + CloudAccountState *CloudAccountProvisioningState `json:"cloudAccountState,omitempty"` + Intent *Intent `json:"intent,omitempty"` + LastOperationStatusDetail *string `json:"lastOperationStatusDetail,omitempty"` + ProductCode *string `json:"productCode,omitempty"` + ProvisioningState *OracleSubscriptionProvisioningState `json:"provisioningState,omitempty"` + SaasSubscriptionId *string `json:"saasSubscriptionId,omitempty"` + TermUnit *string `json:"termUnit,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/model_oraclesubscriptionupdate.go b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/model_oraclesubscriptionupdate.go new file mode 100644 index 00000000000..c95a9cd5426 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/model_oraclesubscriptionupdate.go @@ -0,0 +1,9 @@ +package oraclesubscriptions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OracleSubscriptionUpdate struct { + Plan *PlanUpdate `json:"plan,omitempty"` + Properties *OracleSubscriptionUpdateProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/model_oraclesubscriptionupdateproperties.go b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/model_oraclesubscriptionupdateproperties.go new file mode 100644 index 00000000000..d60eeb53821 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/model_oraclesubscriptionupdateproperties.go @@ -0,0 +1,9 @@ +package oraclesubscriptions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OracleSubscriptionUpdateProperties struct { + Intent *Intent `json:"intent,omitempty"` + ProductCode *string `json:"productCode,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/model_plan.go b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/model_plan.go new file mode 100644 index 00000000000..a34f477722e --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/model_plan.go @@ -0,0 +1,12 @@ +package oraclesubscriptions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Plan struct { + Name string `json:"name"` + Product string `json:"product"` + PromotionCode *string `json:"promotionCode,omitempty"` + Publisher string `json:"publisher"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/model_planupdate.go b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/model_planupdate.go new file mode 100644 index 00000000000..e44262bea92 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/model_planupdate.go @@ -0,0 +1,12 @@ +package oraclesubscriptions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PlanUpdate struct { + Name *string `json:"name,omitempty"` + Product *string `json:"product,omitempty"` + PromotionCode *string `json:"promotionCode,omitempty"` + Publisher *string `json:"publisher,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/model_saassubscriptiondetails.go b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/model_saassubscriptiondetails.go new file mode 100644 index 00000000000..ac942a9834c --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/model_saassubscriptiondetails.go @@ -0,0 +1,37 @@ +package oraclesubscriptions + +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 SaasSubscriptionDetails struct { + Id *string `json:"id,omitempty"` + IsAutoRenew *bool `json:"isAutoRenew,omitempty"` + IsFreeTrial *bool `json:"isFreeTrial,omitempty"` + OfferId *string `json:"offerId,omitempty"` + PlanId *string `json:"planId,omitempty"` + PublisherId *string `json:"publisherId,omitempty"` + PurchaserEmailId *string `json:"purchaserEmailId,omitempty"` + PurchaserTenantId *string `json:"purchaserTenantId,omitempty"` + SaasSubscriptionStatus *string `json:"saasSubscriptionStatus,omitempty"` + SubscriptionName *string `json:"subscriptionName,omitempty"` + TermUnit *string `json:"termUnit,omitempty"` + TimeCreated *string `json:"timeCreated,omitempty"` +} + +func (o *SaasSubscriptionDetails) GetTimeCreatedAsTime() (*time.Time, error) { + if o.TimeCreated == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeCreated, "2006-01-02T15:04:05Z07:00") +} + +func (o *SaasSubscriptionDetails) SetTimeCreatedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeCreated = &formatted +} diff --git a/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/predicates.go b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/predicates.go new file mode 100644 index 00000000000..c59c4fe93bc --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/predicates.go @@ -0,0 +1,27 @@ +package oraclesubscriptions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OracleSubscriptionOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p OracleSubscriptionOperationPredicate) Matches(input OracleSubscription) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/version.go b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/version.go new file mode 100644 index 00000000000..57edceaa23b --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/oraclesubscriptions/version.go @@ -0,0 +1,12 @@ +package oraclesubscriptions + +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-06-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/oraclesubscriptions/%s", defaultApiVersion) +} diff --git a/resource-manager/oracledatabase/2024-06-01/systemversions/README.md b/resource-manager/oracledatabase/2024-06-01/systemversions/README.md new file mode 100644 index 00000000000..ba327c9145f --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/systemversions/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/systemversions` Documentation + +The `systemversions` SDK allows for interaction with the Azure Resource Manager Service `oracledatabase` (API Version `2024-06-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/oracledatabase/2024-06-01/systemversions" +``` + + +### Client Initialization + +```go +client := systemversions.NewSystemVersionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SystemVersionsClient.Get` + +```go +ctx := context.TODO() +id := systemversions.NewSystemVersionID("12345678-1234-9876-4563-123456789012", "locationValue", "systemVersionValue") + +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: `SystemVersionsClient.ListByLocation` + +```go +ctx := context.TODO() +id := systemversions.NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + +// alternatively `client.ListByLocation(ctx, id)` can be used to do batched pagination +items, err := client.ListByLocationComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/oracledatabase/2024-06-01/systemversions/client.go b/resource-manager/oracledatabase/2024-06-01/systemversions/client.go new file mode 100644 index 00000000000..964f6de60c1 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/systemversions/client.go @@ -0,0 +1,26 @@ +package systemversions + +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 SystemVersionsClient struct { + Client *resourcemanager.Client +} + +func NewSystemVersionsClientWithBaseURI(sdkApi sdkEnv.Api) (*SystemVersionsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "systemversions", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SystemVersionsClient: %+v", err) + } + + return &SystemVersionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/oracledatabase/2024-06-01/systemversions/id_location.go b/resource-manager/oracledatabase/2024-06-01/systemversions/id_location.go new file mode 100644 index 00000000000..522b02094c9 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/systemversions/id_location.go @@ -0,0 +1,121 @@ +package systemversions + +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/Oracle.Database/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("staticOracleDatabase", "Oracle.Database", "Oracle.Database"), + 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/oracledatabase/2024-06-01/systemversions/id_location_test.go b/resource-manager/oracledatabase/2024-06-01/systemversions/id_location_test.go new file mode 100644 index 00000000000..a78443dc00f --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/systemversions/id_location_test.go @@ -0,0 +1,237 @@ +package systemversions + +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/Oracle.Database/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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/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/Oracle.Database/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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/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/Oracle.Database/locations/locationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/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/oRaClE.DaTaBaSe/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/oracledatabase/2024-06-01/systemversions/id_systemversion.go b/resource-manager/oracledatabase/2024-06-01/systemversions/id_systemversion.go new file mode 100644 index 00000000000..54af015e094 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/systemversions/id_systemversion.go @@ -0,0 +1,130 @@ +package systemversions + +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(&SystemVersionId{}) +} + +var _ resourceids.ResourceId = &SystemVersionId{} + +// SystemVersionId is a struct representing the Resource ID for a System Version +type SystemVersionId struct { + SubscriptionId string + LocationName string + SystemVersionName string +} + +// NewSystemVersionID returns a new SystemVersionId struct +func NewSystemVersionID(subscriptionId string, locationName string, systemVersionName string) SystemVersionId { + return SystemVersionId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + SystemVersionName: systemVersionName, + } +} + +// ParseSystemVersionID parses 'input' into a SystemVersionId +func ParseSystemVersionID(input string) (*SystemVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SystemVersionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SystemVersionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSystemVersionIDInsensitively parses 'input' case-insensitively into a SystemVersionId +// note: this method should only be used for API response data and not user input +func ParseSystemVersionIDInsensitively(input string) (*SystemVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SystemVersionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SystemVersionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SystemVersionId) 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) + } + + if id.SystemVersionName, ok = input.Parsed["systemVersionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "systemVersionName", input) + } + + return nil +} + +// ValidateSystemVersionID checks that 'input' can be parsed as a System Version ID +func ValidateSystemVersionID(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 := ParseSystemVersionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted System Version ID +func (id SystemVersionId) ID() string { + fmtString := "/subscriptions/%s/providers/Oracle.Database/locations/%s/systemVersions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName, id.SystemVersionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this System Version ID +func (id SystemVersionId) 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("staticOracleDatabase", "Oracle.Database", "Oracle.Database"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationValue"), + resourceids.StaticSegment("staticSystemVersions", "systemVersions", "systemVersions"), + resourceids.UserSpecifiedSegment("systemVersionName", "systemVersionValue"), + } +} + +// String returns a human-readable description of this System Version ID +func (id SystemVersionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + fmt.Sprintf("System Version Name: %q", id.SystemVersionName), + } + return fmt.Sprintf("System Version (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/oracledatabase/2024-06-01/systemversions/id_systemversion_test.go b/resource-manager/oracledatabase/2024-06-01/systemversions/id_systemversion_test.go new file mode 100644 index 00000000000..b67ca68b338 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/systemversions/id_systemversion_test.go @@ -0,0 +1,282 @@ +package systemversions + +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 = &SystemVersionId{} + +func TestNewSystemVersionID(t *testing.T) { + id := NewSystemVersionID("12345678-1234-9876-4563-123456789012", "locationValue", "systemVersionValue") + + 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") + } + + if id.SystemVersionName != "systemVersionValue" { + t.Fatalf("Expected %q but got %q for Segment 'SystemVersionName'", id.SystemVersionName, "systemVersionValue") + } +} + +func TestFormatSystemVersionID(t *testing.T) { + actual := NewSystemVersionID("12345678-1234-9876-4563-123456789012", "locationValue", "systemVersionValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/systemVersions/systemVersionValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSystemVersionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SystemVersionId + }{ + { + // 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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/systemVersions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/systemVersions/systemVersionValue", + Expected: &SystemVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + SystemVersionName: "systemVersionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/systemVersions/systemVersionValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSystemVersionID(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) + } + + if actual.SystemVersionName != v.Expected.SystemVersionName { + t.Fatalf("Expected %q but got %q for SystemVersionName", v.Expected.SystemVersionName, actual.SystemVersionName) + } + + } +} + +func TestParseSystemVersionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SystemVersionId + }{ + { + // 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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs/lOcAtIoNvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/systemVersions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs/lOcAtIoNvAlUe/sYsTeMvErSiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/systemVersions/systemVersionValue", + Expected: &SystemVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + SystemVersionName: "systemVersionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Oracle.Database/locations/locationValue/systemVersions/systemVersionValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs/lOcAtIoNvAlUe/sYsTeMvErSiOnS/sYsTeMvErSiOnVaLuE", + Expected: &SystemVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNvAlUe", + SystemVersionName: "sYsTeMvErSiOnVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/oRaClE.DaTaBaSe/lOcAtIoNs/lOcAtIoNvAlUe/sYsTeMvErSiOnS/sYsTeMvErSiOnVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSystemVersionIDInsensitively(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) + } + + if actual.SystemVersionName != v.Expected.SystemVersionName { + t.Fatalf("Expected %q but got %q for SystemVersionName", v.Expected.SystemVersionName, actual.SystemVersionName) + } + + } +} + +func TestSegmentsForSystemVersionId(t *testing.T) { + segments := SystemVersionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SystemVersionId 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/oracledatabase/2024-06-01/systemversions/method_get.go b/resource-manager/oracledatabase/2024-06-01/systemversions/method_get.go new file mode 100644 index 00000000000..da328bb1b48 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/systemversions/method_get.go @@ -0,0 +1,54 @@ +package systemversions + +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 *SystemVersion +} + +// Get ... +func (c SystemVersionsClient) Get(ctx context.Context, id SystemVersionId) (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 SystemVersion + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/oracledatabase/2024-06-01/systemversions/method_listbylocation.go b/resource-manager/oracledatabase/2024-06-01/systemversions/method_listbylocation.go new file mode 100644 index 00000000000..f1250239c6d --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/systemversions/method_listbylocation.go @@ -0,0 +1,105 @@ +package systemversions + +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 ListByLocationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SystemVersion +} + +type ListByLocationCompleteResult struct { + LatestHttpResponse *http.Response + Items []SystemVersion +} + +type ListByLocationCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByLocationCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByLocation ... +func (c SystemVersionsClient) ListByLocation(ctx context.Context, id LocationId) (result ListByLocationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByLocationCustomPager{}, + Path: fmt.Sprintf("%s/systemVersions", 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 *[]SystemVersion `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByLocationComplete retrieves all the results into a single object +func (c SystemVersionsClient) ListByLocationComplete(ctx context.Context, id LocationId) (ListByLocationCompleteResult, error) { + return c.ListByLocationCompleteMatchingPredicate(ctx, id, SystemVersionOperationPredicate{}) +} + +// ListByLocationCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SystemVersionsClient) ListByLocationCompleteMatchingPredicate(ctx context.Context, id LocationId, predicate SystemVersionOperationPredicate) (result ListByLocationCompleteResult, err error) { + items := make([]SystemVersion, 0) + + resp, err := c.ListByLocation(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByLocationCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/oracledatabase/2024-06-01/systemversions/model_systemversion.go b/resource-manager/oracledatabase/2024-06-01/systemversions/model_systemversion.go new file mode 100644 index 00000000000..dc4bb7d6d35 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/systemversions/model_systemversion.go @@ -0,0 +1,16 @@ +package systemversions + +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 SystemVersion struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SystemVersionProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/systemversions/model_systemversionproperties.go b/resource-manager/oracledatabase/2024-06-01/systemversions/model_systemversionproperties.go new file mode 100644 index 00000000000..5eda0476133 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/systemversions/model_systemversionproperties.go @@ -0,0 +1,8 @@ +package systemversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SystemVersionProperties struct { + SystemVersion *string `json:"systemVersion,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/systemversions/predicates.go b/resource-manager/oracledatabase/2024-06-01/systemversions/predicates.go new file mode 100644 index 00000000000..d2d884b970c --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/systemversions/predicates.go @@ -0,0 +1,27 @@ +package systemversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SystemVersionOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p SystemVersionOperationPredicate) Matches(input SystemVersion) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/oracledatabase/2024-06-01/systemversions/version.go b/resource-manager/oracledatabase/2024-06-01/systemversions/version.go new file mode 100644 index 00000000000..b0f8f194d46 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/systemversions/version.go @@ -0,0 +1,12 @@ +package systemversions + +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-06-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/systemversions/%s", defaultApiVersion) +} diff --git a/resource-manager/oracledatabase/2024-06-01/virtualnetworkaddresses/README.md b/resource-manager/oracledatabase/2024-06-01/virtualnetworkaddresses/README.md new file mode 100644 index 00000000000..5fd92c2eeff --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/virtualnetworkaddresses/README.md @@ -0,0 +1,82 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2024-06-01/virtualnetworkaddresses` Documentation + +The `virtualnetworkaddresses` SDK allows for interaction with the Azure Resource Manager Service `oracledatabase` (API Version `2024-06-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/oracledatabase/2024-06-01/virtualnetworkaddresses" +``` + + +### Client Initialization + +```go +client := virtualnetworkaddresses.NewVirtualNetworkAddressesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `VirtualNetworkAddressesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := virtualnetworkaddresses.NewVirtualNetworkAddressID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudVmClusterValue", "virtualNetworkAddressValue") + +payload := virtualnetworkaddresses.VirtualNetworkAddress{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworkAddressesClient.Delete` + +```go +ctx := context.TODO() +id := virtualnetworkaddresses.NewVirtualNetworkAddressID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudVmClusterValue", "virtualNetworkAddressValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworkAddressesClient.Get` + +```go +ctx := context.TODO() +id := virtualnetworkaddresses.NewVirtualNetworkAddressID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudVmClusterValue", "virtualNetworkAddressValue") + +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: `VirtualNetworkAddressesClient.ListByCloudVMCluster` + +```go +ctx := context.TODO() +id := virtualnetworkaddresses.NewCloudVMClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudVmClusterValue") + +// alternatively `client.ListByCloudVMCluster(ctx, id)` can be used to do batched pagination +items, err := client.ListByCloudVMClusterComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/oracledatabase/2024-06-01/virtualnetworkaddresses/client.go b/resource-manager/oracledatabase/2024-06-01/virtualnetworkaddresses/client.go new file mode 100644 index 00000000000..6c8968525ed --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/virtualnetworkaddresses/client.go @@ -0,0 +1,26 @@ +package virtualnetworkaddresses + +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 VirtualNetworkAddressesClient struct { + Client *resourcemanager.Client +} + +func NewVirtualNetworkAddressesClientWithBaseURI(sdkApi sdkEnv.Api) (*VirtualNetworkAddressesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "virtualnetworkaddresses", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating VirtualNetworkAddressesClient: %+v", err) + } + + return &VirtualNetworkAddressesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/oracledatabase/2024-06-01/virtualnetworkaddresses/constants.go b/resource-manager/oracledatabase/2024-06-01/virtualnetworkaddresses/constants.go new file mode 100644 index 00000000000..67d5e6fa561 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/virtualnetworkaddresses/constants.go @@ -0,0 +1,107 @@ +package virtualnetworkaddresses + +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 AzureResourceProvisioningState string + +const ( + AzureResourceProvisioningStateCanceled AzureResourceProvisioningState = "Canceled" + AzureResourceProvisioningStateFailed AzureResourceProvisioningState = "Failed" + AzureResourceProvisioningStateProvisioning AzureResourceProvisioningState = "Provisioning" + AzureResourceProvisioningStateSucceeded AzureResourceProvisioningState = "Succeeded" +) + +func PossibleValuesForAzureResourceProvisioningState() []string { + return []string{ + string(AzureResourceProvisioningStateCanceled), + string(AzureResourceProvisioningStateFailed), + string(AzureResourceProvisioningStateProvisioning), + string(AzureResourceProvisioningStateSucceeded), + } +} + +func (s *AzureResourceProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureResourceProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureResourceProvisioningState(input string) (*AzureResourceProvisioningState, error) { + vals := map[string]AzureResourceProvisioningState{ + "canceled": AzureResourceProvisioningStateCanceled, + "failed": AzureResourceProvisioningStateFailed, + "provisioning": AzureResourceProvisioningStateProvisioning, + "succeeded": AzureResourceProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureResourceProvisioningState(input) + return &out, nil +} + +type VirtualNetworkAddressLifecycleState string + +const ( + VirtualNetworkAddressLifecycleStateAvailable VirtualNetworkAddressLifecycleState = "Available" + VirtualNetworkAddressLifecycleStateFailed VirtualNetworkAddressLifecycleState = "Failed" + VirtualNetworkAddressLifecycleStateProvisioning VirtualNetworkAddressLifecycleState = "Provisioning" + VirtualNetworkAddressLifecycleStateTerminated VirtualNetworkAddressLifecycleState = "Terminated" + VirtualNetworkAddressLifecycleStateTerminating VirtualNetworkAddressLifecycleState = "Terminating" +) + +func PossibleValuesForVirtualNetworkAddressLifecycleState() []string { + return []string{ + string(VirtualNetworkAddressLifecycleStateAvailable), + string(VirtualNetworkAddressLifecycleStateFailed), + string(VirtualNetworkAddressLifecycleStateProvisioning), + string(VirtualNetworkAddressLifecycleStateTerminated), + string(VirtualNetworkAddressLifecycleStateTerminating), + } +} + +func (s *VirtualNetworkAddressLifecycleState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkAddressLifecycleState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkAddressLifecycleState(input string) (*VirtualNetworkAddressLifecycleState, error) { + vals := map[string]VirtualNetworkAddressLifecycleState{ + "available": VirtualNetworkAddressLifecycleStateAvailable, + "failed": VirtualNetworkAddressLifecycleStateFailed, + "provisioning": VirtualNetworkAddressLifecycleStateProvisioning, + "terminated": VirtualNetworkAddressLifecycleStateTerminated, + "terminating": VirtualNetworkAddressLifecycleStateTerminating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkAddressLifecycleState(input) + return &out, nil +} diff --git a/resource-manager/oracledatabase/2024-06-01/virtualnetworkaddresses/id_cloudvmcluster.go b/resource-manager/oracledatabase/2024-06-01/virtualnetworkaddresses/id_cloudvmcluster.go new file mode 100644 index 00000000000..e755134d59f --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/virtualnetworkaddresses/id_cloudvmcluster.go @@ -0,0 +1,130 @@ +package virtualnetworkaddresses + +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(&CloudVMClusterId{}) +} + +var _ resourceids.ResourceId = &CloudVMClusterId{} + +// CloudVMClusterId is a struct representing the Resource ID for a Cloud V M Cluster +type CloudVMClusterId struct { + SubscriptionId string + ResourceGroupName string + CloudVmClusterName string +} + +// NewCloudVMClusterID returns a new CloudVMClusterId struct +func NewCloudVMClusterID(subscriptionId string, resourceGroupName string, cloudVmClusterName string) CloudVMClusterId { + return CloudVMClusterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CloudVmClusterName: cloudVmClusterName, + } +} + +// ParseCloudVMClusterID parses 'input' into a CloudVMClusterId +func ParseCloudVMClusterID(input string) (*CloudVMClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&CloudVMClusterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CloudVMClusterId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCloudVMClusterIDInsensitively parses 'input' case-insensitively into a CloudVMClusterId +// note: this method should only be used for API response data and not user input +func ParseCloudVMClusterIDInsensitively(input string) (*CloudVMClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&CloudVMClusterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CloudVMClusterId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CloudVMClusterId) 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.CloudVmClusterName, ok = input.Parsed["cloudVmClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "cloudVmClusterName", input) + } + + return nil +} + +// ValidateCloudVMClusterID checks that 'input' can be parsed as a Cloud V M Cluster ID +func ValidateCloudVMClusterID(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 := ParseCloudVMClusterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Cloud V M Cluster ID +func (id CloudVMClusterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Oracle.Database/cloudVmClusters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CloudVmClusterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Cloud V M Cluster ID +func (id CloudVMClusterId) 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("staticOracleDatabase", "Oracle.Database", "Oracle.Database"), + resourceids.StaticSegment("staticCloudVmClusters", "cloudVmClusters", "cloudVmClusters"), + resourceids.UserSpecifiedSegment("cloudVmClusterName", "cloudVmClusterValue"), + } +} + +// String returns a human-readable description of this Cloud V M Cluster ID +func (id CloudVMClusterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cloud Vm Cluster Name: %q", id.CloudVmClusterName), + } + return fmt.Sprintf("Cloud V M Cluster (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/oracledatabase/2024-06-01/virtualnetworkaddresses/id_cloudvmcluster_test.go b/resource-manager/oracledatabase/2024-06-01/virtualnetworkaddresses/id_cloudvmcluster_test.go new file mode 100644 index 00000000000..7fed45336b5 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/virtualnetworkaddresses/id_cloudvmcluster_test.go @@ -0,0 +1,282 @@ +package virtualnetworkaddresses + +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 = &CloudVMClusterId{} + +func TestNewCloudVMClusterID(t *testing.T) { + id := NewCloudVMClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudVmClusterValue") + + 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.CloudVmClusterName != "cloudVmClusterValue" { + t.Fatalf("Expected %q but got %q for Segment 'CloudVmClusterName'", id.CloudVmClusterName, "cloudVmClusterValue") + } +} + +func TestFormatCloudVMClusterID(t *testing.T) { + actual := NewCloudVMClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudVmClusterValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudVmClusters/cloudVmClusterValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCloudVMClusterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CloudVMClusterId + }{ + { + // 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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudVmClusters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudVmClusters/cloudVmClusterValue", + Expected: &CloudVMClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudVmClusterName: "cloudVmClusterValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudVmClusters/cloudVmClusterValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCloudVMClusterID(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.CloudVmClusterName != v.Expected.CloudVmClusterName { + t.Fatalf("Expected %q but got %q for CloudVmClusterName", v.Expected.CloudVmClusterName, actual.CloudVmClusterName) + } + + } +} + +func TestParseCloudVMClusterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CloudVMClusterId + }{ + { + // 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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudVmClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe/cLoUdVmClUsTeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudVmClusters/cloudVmClusterValue", + Expected: &CloudVMClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudVmClusterName: "cloudVmClusterValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudVmClusters/cloudVmClusterValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe/cLoUdVmClUsTeRs/cLoUdVmClUsTeRvAlUe", + Expected: &CloudVMClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CloudVmClusterName: "cLoUdVmClUsTeRvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe/cLoUdVmClUsTeRs/cLoUdVmClUsTeRvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCloudVMClusterIDInsensitively(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.CloudVmClusterName != v.Expected.CloudVmClusterName { + t.Fatalf("Expected %q but got %q for CloudVmClusterName", v.Expected.CloudVmClusterName, actual.CloudVmClusterName) + } + + } +} + +func TestSegmentsForCloudVMClusterId(t *testing.T) { + segments := CloudVMClusterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CloudVMClusterId 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/oracledatabase/2024-06-01/virtualnetworkaddresses/id_virtualnetworkaddress.go b/resource-manager/oracledatabase/2024-06-01/virtualnetworkaddresses/id_virtualnetworkaddress.go new file mode 100644 index 00000000000..e49281decaa --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/virtualnetworkaddresses/id_virtualnetworkaddress.go @@ -0,0 +1,139 @@ +package virtualnetworkaddresses + +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(&VirtualNetworkAddressId{}) +} + +var _ resourceids.ResourceId = &VirtualNetworkAddressId{} + +// VirtualNetworkAddressId is a struct representing the Resource ID for a Virtual Network Address +type VirtualNetworkAddressId struct { + SubscriptionId string + ResourceGroupName string + CloudVmClusterName string + VirtualNetworkAddressName string +} + +// NewVirtualNetworkAddressID returns a new VirtualNetworkAddressId struct +func NewVirtualNetworkAddressID(subscriptionId string, resourceGroupName string, cloudVmClusterName string, virtualNetworkAddressName string) VirtualNetworkAddressId { + return VirtualNetworkAddressId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CloudVmClusterName: cloudVmClusterName, + VirtualNetworkAddressName: virtualNetworkAddressName, + } +} + +// ParseVirtualNetworkAddressID parses 'input' into a VirtualNetworkAddressId +func ParseVirtualNetworkAddressID(input string) (*VirtualNetworkAddressId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualNetworkAddressId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualNetworkAddressId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVirtualNetworkAddressIDInsensitively parses 'input' case-insensitively into a VirtualNetworkAddressId +// note: this method should only be used for API response data and not user input +func ParseVirtualNetworkAddressIDInsensitively(input string) (*VirtualNetworkAddressId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualNetworkAddressId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualNetworkAddressId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VirtualNetworkAddressId) 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.CloudVmClusterName, ok = input.Parsed["cloudVmClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "cloudVmClusterName", input) + } + + if id.VirtualNetworkAddressName, ok = input.Parsed["virtualNetworkAddressName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualNetworkAddressName", input) + } + + return nil +} + +// ValidateVirtualNetworkAddressID checks that 'input' can be parsed as a Virtual Network Address ID +func ValidateVirtualNetworkAddressID(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 := ParseVirtualNetworkAddressID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Virtual Network Address ID +func (id VirtualNetworkAddressId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Oracle.Database/cloudVmClusters/%s/virtualNetworkAddresses/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CloudVmClusterName, id.VirtualNetworkAddressName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Virtual Network Address ID +func (id VirtualNetworkAddressId) 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("staticOracleDatabase", "Oracle.Database", "Oracle.Database"), + resourceids.StaticSegment("staticCloudVmClusters", "cloudVmClusters", "cloudVmClusters"), + resourceids.UserSpecifiedSegment("cloudVmClusterName", "cloudVmClusterValue"), + resourceids.StaticSegment("staticVirtualNetworkAddresses", "virtualNetworkAddresses", "virtualNetworkAddresses"), + resourceids.UserSpecifiedSegment("virtualNetworkAddressName", "virtualNetworkAddressValue"), + } +} + +// String returns a human-readable description of this Virtual Network Address ID +func (id VirtualNetworkAddressId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cloud Vm Cluster Name: %q", id.CloudVmClusterName), + fmt.Sprintf("Virtual Network Address Name: %q", id.VirtualNetworkAddressName), + } + return fmt.Sprintf("Virtual Network Address (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/oracledatabase/2024-06-01/virtualnetworkaddresses/id_virtualnetworkaddress_test.go b/resource-manager/oracledatabase/2024-06-01/virtualnetworkaddresses/id_virtualnetworkaddress_test.go new file mode 100644 index 00000000000..06d43e04fea --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/virtualnetworkaddresses/id_virtualnetworkaddress_test.go @@ -0,0 +1,327 @@ +package virtualnetworkaddresses + +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 = &VirtualNetworkAddressId{} + +func TestNewVirtualNetworkAddressID(t *testing.T) { + id := NewVirtualNetworkAddressID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudVmClusterValue", "virtualNetworkAddressValue") + + 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.CloudVmClusterName != "cloudVmClusterValue" { + t.Fatalf("Expected %q but got %q for Segment 'CloudVmClusterName'", id.CloudVmClusterName, "cloudVmClusterValue") + } + + if id.VirtualNetworkAddressName != "virtualNetworkAddressValue" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualNetworkAddressName'", id.VirtualNetworkAddressName, "virtualNetworkAddressValue") + } +} + +func TestFormatVirtualNetworkAddressID(t *testing.T) { + actual := NewVirtualNetworkAddressID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudVmClusterValue", "virtualNetworkAddressValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudVmClusters/cloudVmClusterValue/virtualNetworkAddresses/virtualNetworkAddressValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVirtualNetworkAddressID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualNetworkAddressId + }{ + { + // 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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudVmClusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudVmClusters/cloudVmClusterValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudVmClusters/cloudVmClusterValue/virtualNetworkAddresses", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudVmClusters/cloudVmClusterValue/virtualNetworkAddresses/virtualNetworkAddressValue", + Expected: &VirtualNetworkAddressId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudVmClusterName: "cloudVmClusterValue", + VirtualNetworkAddressName: "virtualNetworkAddressValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudVmClusters/cloudVmClusterValue/virtualNetworkAddresses/virtualNetworkAddressValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualNetworkAddressID(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.CloudVmClusterName != v.Expected.CloudVmClusterName { + t.Fatalf("Expected %q but got %q for CloudVmClusterName", v.Expected.CloudVmClusterName, actual.CloudVmClusterName) + } + + if actual.VirtualNetworkAddressName != v.Expected.VirtualNetworkAddressName { + t.Fatalf("Expected %q but got %q for VirtualNetworkAddressName", v.Expected.VirtualNetworkAddressName, actual.VirtualNetworkAddressName) + } + + } +} + +func TestParseVirtualNetworkAddressIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualNetworkAddressId + }{ + { + // 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/Oracle.Database", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudVmClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe/cLoUdVmClUsTeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudVmClusters/cloudVmClusterValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe/cLoUdVmClUsTeRs/cLoUdVmClUsTeRvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudVmClusters/cloudVmClusterValue/virtualNetworkAddresses", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe/cLoUdVmClUsTeRs/cLoUdVmClUsTeRvAlUe/vIrTuAlNeTwOrKaDdReSsEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudVmClusters/cloudVmClusterValue/virtualNetworkAddresses/virtualNetworkAddressValue", + Expected: &VirtualNetworkAddressId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudVmClusterName: "cloudVmClusterValue", + VirtualNetworkAddressName: "virtualNetworkAddressValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Oracle.Database/cloudVmClusters/cloudVmClusterValue/virtualNetworkAddresses/virtualNetworkAddressValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe/cLoUdVmClUsTeRs/cLoUdVmClUsTeRvAlUe/vIrTuAlNeTwOrKaDdReSsEs/vIrTuAlNeTwOrKaDdReSsVaLuE", + Expected: &VirtualNetworkAddressId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CloudVmClusterName: "cLoUdVmClUsTeRvAlUe", + VirtualNetworkAddressName: "vIrTuAlNeTwOrKaDdReSsVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/oRaClE.DaTaBaSe/cLoUdVmClUsTeRs/cLoUdVmClUsTeRvAlUe/vIrTuAlNeTwOrKaDdReSsEs/vIrTuAlNeTwOrKaDdReSsVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualNetworkAddressIDInsensitively(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.CloudVmClusterName != v.Expected.CloudVmClusterName { + t.Fatalf("Expected %q but got %q for CloudVmClusterName", v.Expected.CloudVmClusterName, actual.CloudVmClusterName) + } + + if actual.VirtualNetworkAddressName != v.Expected.VirtualNetworkAddressName { + t.Fatalf("Expected %q but got %q for VirtualNetworkAddressName", v.Expected.VirtualNetworkAddressName, actual.VirtualNetworkAddressName) + } + + } +} + +func TestSegmentsForVirtualNetworkAddressId(t *testing.T) { + segments := VirtualNetworkAddressId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VirtualNetworkAddressId 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/oracledatabase/2024-06-01/virtualnetworkaddresses/method_createorupdate.go b/resource-manager/oracledatabase/2024-06-01/virtualnetworkaddresses/method_createorupdate.go new file mode 100644 index 00000000000..dd9d12a988d --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/virtualnetworkaddresses/method_createorupdate.go @@ -0,0 +1,75 @@ +package virtualnetworkaddresses + +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 *VirtualNetworkAddress +} + +// CreateOrUpdate ... +func (c VirtualNetworkAddressesClient) CreateOrUpdate(ctx context.Context, id VirtualNetworkAddressId, input VirtualNetworkAddress) (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 VirtualNetworkAddressesClient) CreateOrUpdateThenPoll(ctx context.Context, id VirtualNetworkAddressId, input VirtualNetworkAddress) 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/oracledatabase/2024-06-01/virtualnetworkaddresses/method_delete.go b/resource-manager/oracledatabase/2024-06-01/virtualnetworkaddresses/method_delete.go new file mode 100644 index 00000000000..0cbd45c9648 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/virtualnetworkaddresses/method_delete.go @@ -0,0 +1,70 @@ +package virtualnetworkaddresses + +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 VirtualNetworkAddressesClient) Delete(ctx context.Context, id VirtualNetworkAddressId) (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 VirtualNetworkAddressesClient) DeleteThenPoll(ctx context.Context, id VirtualNetworkAddressId) 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/oracledatabase/2024-06-01/virtualnetworkaddresses/method_get.go b/resource-manager/oracledatabase/2024-06-01/virtualnetworkaddresses/method_get.go new file mode 100644 index 00000000000..151f06223ee --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/virtualnetworkaddresses/method_get.go @@ -0,0 +1,54 @@ +package virtualnetworkaddresses + +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 *VirtualNetworkAddress +} + +// Get ... +func (c VirtualNetworkAddressesClient) Get(ctx context.Context, id VirtualNetworkAddressId) (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 VirtualNetworkAddress + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/oracledatabase/2024-06-01/virtualnetworkaddresses/method_listbycloudvmcluster.go b/resource-manager/oracledatabase/2024-06-01/virtualnetworkaddresses/method_listbycloudvmcluster.go new file mode 100644 index 00000000000..81eba745ec7 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/virtualnetworkaddresses/method_listbycloudvmcluster.go @@ -0,0 +1,105 @@ +package virtualnetworkaddresses + +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 ListByCloudVMClusterOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VirtualNetworkAddress +} + +type ListByCloudVMClusterCompleteResult struct { + LatestHttpResponse *http.Response + Items []VirtualNetworkAddress +} + +type ListByCloudVMClusterCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByCloudVMClusterCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByCloudVMCluster ... +func (c VirtualNetworkAddressesClient) ListByCloudVMCluster(ctx context.Context, id CloudVMClusterId) (result ListByCloudVMClusterOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByCloudVMClusterCustomPager{}, + Path: fmt.Sprintf("%s/virtualNetworkAddresses", 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 *[]VirtualNetworkAddress `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByCloudVMClusterComplete retrieves all the results into a single object +func (c VirtualNetworkAddressesClient) ListByCloudVMClusterComplete(ctx context.Context, id CloudVMClusterId) (ListByCloudVMClusterCompleteResult, error) { + return c.ListByCloudVMClusterCompleteMatchingPredicate(ctx, id, VirtualNetworkAddressOperationPredicate{}) +} + +// ListByCloudVMClusterCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualNetworkAddressesClient) ListByCloudVMClusterCompleteMatchingPredicate(ctx context.Context, id CloudVMClusterId, predicate VirtualNetworkAddressOperationPredicate) (result ListByCloudVMClusterCompleteResult, err error) { + items := make([]VirtualNetworkAddress, 0) + + resp, err := c.ListByCloudVMCluster(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = ListByCloudVMClusterCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/oracledatabase/2024-06-01/virtualnetworkaddresses/model_virtualnetworkaddress.go b/resource-manager/oracledatabase/2024-06-01/virtualnetworkaddresses/model_virtualnetworkaddress.go new file mode 100644 index 00000000000..2451c7ae562 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/virtualnetworkaddresses/model_virtualnetworkaddress.go @@ -0,0 +1,16 @@ +package virtualnetworkaddresses + +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 VirtualNetworkAddress struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VirtualNetworkAddressProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/oracledatabase/2024-06-01/virtualnetworkaddresses/model_virtualnetworkaddressproperties.go b/resource-manager/oracledatabase/2024-06-01/virtualnetworkaddresses/model_virtualnetworkaddressproperties.go new file mode 100644 index 00000000000..807d373de87 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/virtualnetworkaddresses/model_virtualnetworkaddressproperties.go @@ -0,0 +1,33 @@ +package virtualnetworkaddresses + +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 VirtualNetworkAddressProperties struct { + Domain *string `json:"domain,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + LifecycleDetails *string `json:"lifecycleDetails,omitempty"` + LifecycleState *VirtualNetworkAddressLifecycleState `json:"lifecycleState,omitempty"` + Ocid *string `json:"ocid,omitempty"` + ProvisioningState *AzureResourceProvisioningState `json:"provisioningState,omitempty"` + TimeAssigned *string `json:"timeAssigned,omitempty"` + VMOcid *string `json:"vmOcid,omitempty"` +} + +func (o *VirtualNetworkAddressProperties) GetTimeAssignedAsTime() (*time.Time, error) { + if o.TimeAssigned == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeAssigned, "2006-01-02T15:04:05Z07:00") +} + +func (o *VirtualNetworkAddressProperties) SetTimeAssignedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeAssigned = &formatted +} diff --git a/resource-manager/oracledatabase/2024-06-01/virtualnetworkaddresses/predicates.go b/resource-manager/oracledatabase/2024-06-01/virtualnetworkaddresses/predicates.go new file mode 100644 index 00000000000..c0416c10a31 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/virtualnetworkaddresses/predicates.go @@ -0,0 +1,27 @@ +package virtualnetworkaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkAddressOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p VirtualNetworkAddressOperationPredicate) Matches(input VirtualNetworkAddress) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/oracledatabase/2024-06-01/virtualnetworkaddresses/version.go b/resource-manager/oracledatabase/2024-06-01/virtualnetworkaddresses/version.go new file mode 100644 index 00000000000..9b5dd6bad36 --- /dev/null +++ b/resource-manager/oracledatabase/2024-06-01/virtualnetworkaddresses/version.go @@ -0,0 +1,12 @@ +package virtualnetworkaddresses + +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-06-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/virtualnetworkaddresses/%s", defaultApiVersion) +}